This documentation provides instructions on how to deploy a Development Network (DevNet) on AWS using Terraform.
The devnet
directory consists of reusable Terraform modules.
The nets
directory holds specific configurations for individual networks.
Said another way, the nets
are instances of devnet
.
Before proceeding with the deployment, ensure the following prerequisites are met:
- Install the AWS CLI tool and run
aws configure
to set up your Access Key ID and Secret Access Key obtained from the AWS console. - Install the Session Manager plugin for AWS CLI.
- Install Terraform.
To provision the Avail Network, follow these steps:
- Deploy your avail network.
- If your Avail Network is publicly available, pass the
avail_hostname
andavail_port
variables to the Terraform script bellow using the-var
or-var-file
arguments. - If your Avail Network is private and located in the same region and AWS account as this deployment, use the
avail_peer
variable to configure the peering. Typically, theroute53_zone_private_id
,route_table_private_ids
andvpc_id
will be outputted from the Avail deployment Terraform script.
To provision the necessary AWS resources and deploy the nodes, perform the following steps:
- The Terraform script requires the
github_token
variable to access the release from the private repository. - Open a terminal and navigate to the
./deployment/devnet
directory. - Initialize Terraform by running
terraform init
. - Apply the Terraform configuration using the command
terraform apply -var github_token=$G_TOKEN
.
- You can customize the deployment options by specifying Terraform variables in the format
terraform apply -var <key>=<value>
orterraform apply -var-file="<tfvars-filename>"
. - For available variables to customize the deployment, refer to the
devnet/variables.tf
file.
To deploy your own DevNet for testing purposes, follow these steps:
- If you prefer not to push your configuration to the git repository, you have the option to create a Terraform module within the
nets/private
folder. This folder is specifically ignored by git. - If you wish to persist your configuration to git, create a Terraform module under the
nets/<devnet-name>
folder. - Inside the
nets/private
folder, create a file namedmain.tf
. - Use the provided template below to fill in the required details:
terraform {
backend "s3" {
bucket = "availsl-tf-states"
key = "state/op-evm/<deployment-name>"
region = "<region>"
}
}
module "devnet" {
source = "../../devnet"
deployment_name = "<deployment-name>"
region = "<region>"
base_ami = "<ami>" # Latest ubuntu ami
avail_hostname = "internal-rpc.testnetsl.avail.private"
release = "v0.1.0" # Use latest release
avail_peer = {
route53_zone_private_id = "<route53-zone>"
route_table_private_ids = [
"<route-table-1>",
"<route-table-2>",
"<route-table-3>",
]
vpc_id = "<vpc-id>"
}
github_token = "<github-token>"
}
To debug instances in the DevNet, follow these steps:
Run the following commands in the terminal:
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/sessionmanager-bundle.zip" -o "sessionmanager-bundle.zip"
unzip sessionmanager-bundle.zip
sudo ./sessionmanager-bundle/install -i /usr/local/sessionmanagerplugin -b /usr/local/bin/session-manager-plugin
- Retrieve the private key from Terraform by running the command
terraform output --raw ssh_pk > key.pem
. - Set the correct permissions for the private key file using
chmod 600 key.pem
.
- Open the
~/.ssh/config
file using a text editor. - Add the following lines to the file:
host i-* mi-*
ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
- Save the changes and set the correct permissions for the
~/.ssh/config
file usingchmod 600 ~/.ssh/config
. - Connect to the instance using SSH with the following command (replace
[INSTANCE-ID]
with the actual instance ID):
- AWS Session Manager Plugin Installation Guide
- AWS Session Manager Troubleshooting Guide
- AWS Session Manager Getting Started Guide
- Open a new console and run the command
ssh -N -L 8888:internal-rpc.testnet04.avail.private:80 -i key.pem ubuntu@<instance-id>
. - In another console, run the command
ssh -N -L 9944:internal-rpc.testnet04.avail.private:8546 -i key.pem ubuntu@<instance-id>
. - Open your browser and access
localhost:8888
. - In the Avail Explorer, select the Local Node option (with address:
127.0.0.1:9944
) in the networks settings menu, located under development, and press Switch. - Explore the blocks in the Avail Explorer!