To set up the infrastructure, you need to clone the tokamak-thanos-stack repository to your local machine.

Visit the link below to clone the repository:

The tokamak-thanos-stack repository is structured as follows:

In this guide, we will use the Terraform code to set up the infrastructure that forms the foundation of the Thanos chain.

Configure env

Before deploying the infrastructure with Terraform, you need to set up environment variables. we manage the environment variables by creating a .envrc file.

  1. Go to terraform directory

    cd terraform
    
  2. Copy .envrc.example file to .envrc.

    cp .envrc.example .envrc
    
  3. Please fill in the values for the items listed below in the copied file.

    <aside> 💡

    Note to env configure

    1. Variables with default values do not need to be modified.
    2. You can ignore TF_VAR_backend_bucket_name for now, as it will be filled in after configuring the Terraform backend.
    3. The ARN of the IAM user can be found in the EC2 console under Users > User name > Summary tab. </aside>

    When you've filled it all in, it should look like this:

    # .envrc file
    
    # Init variables
    export TF_VAR_thanos_stack_name=thanos-stack-example
    export TF_VAR_aws_region=ap-northeast-2
    
    # Backend variables
    export TF_VAR_backend_bucket_name=
    
    export TF_CLI_ARGS_init="-backend-config='bucket=$TF_VAR_backend_bucket_name'"
    export TF_CLI_ARGS_init="$TF_CLI_ARGS_init -backend-config='region=${TF_VAR_aws_region}'"
    
    # Sequencer private keys
    export TF_VAR_sequencer_key=0xYourSequencerSecretKey
    export TF_VAR_batcher_key=0xYourBatcherSecretKey
    export TF_VAR_proposer_key=0xYourProposerSecretKey
    export TF_VAR_challenger_key=0xYourChallengerSecretKey
    
    # VPC variables
    export TF_VAR_azs='["ap-northeast-2a", "ap-northeast-2c"]'
    export TF_VAR_vpc_cidr="192.168.0.0/16"
    export TF_VAR_vpc_name="${TF_VAR_thanos_stack_name}/VPC"
    
    # EKS
    export TF_VAR_eks_cluster_admins='["arn:aws:iam::111111111111:user/thanos-stack"]'
    
    # Uploading chain config files
    export TF_VAR_genesis_file_path="config-files/genesis.json"
    export TF_VAR_rollup_file_path="config-files/rollup.json"
    export TF_VAR_prestate_file_path="config-files/prestate.json"
    export TF_VAR_prestate_hash="0x03ab262ce124af0d5d328e09bf886a2b272fe960138115ad8b94fdc3034e3155"
    
    # Thanos config
    export TF_VAR_stack_deployments_path="~/tokamak-thanos/packages/tokamak/contracts-bedrock/deployments/1-deploy.json"
    export TF_VAR_stack_l1_rpc_url="YourRPCEndpointURL"
    export TF_VAR_stack_l1_rpc_provider="alchemy"
    export TF_VAR_stack_l1_beacon_url="YourBeaconRPCEndpointURL"
    
  4. Save and apply the environment variables using the following command.

    $ direnv allow
    
    direnv: loading ~/Documents/tokamak-network/tokamak-thanos-stack/terraform/.envrc
    direnv: export +TF_CLI_ARGS_init +TF_VAR_aws_region +TF_VAR_azs +TF_VAR_backend_bucket_name +TF_VAR_batcher_key +TF_VAR_challenger_key +TF_VAR_eks_cluster_admins +TF_VAR_genesis_file_path +TF_VAR_prestate_file_path +TF_VAR_prestate_hash +TF_VAR_proposer_key +TF_VAR_rollup_file_path +TF_VAR_sequencer_key +TF_VAR_stack_deployments_path +TF_VAR_stack_l1_beacon_url +TF_VAR_stack_l1_rpc_provider +TF_VAR_stack_l1_rpc_url +TF_VAR_thanos_stack_name +TF_VAR_vpc_cidr +TF_VAR_vpc_name
    

Make backend