From 338fb86bcde6fda598f4942460aa063ac6b34e43 Mon Sep 17 00:00:00 2001 From: benjamin202410 Date: Thu, 31 Oct 2024 22:43:07 -0700 Subject: [PATCH] downsize devnet rpc (#724) Co-authored-by: Name --- cicd/devnet/terraform/main.tf | 1 - cicd/devnet/terraform/module/region/main.tf | 1 - cicd/devnet/terraform/s3.tf | 1 - cicd/devnet/terraform/variables.tf | 13 ++------- cicd/terraform/main.tf | 10 +++---- cicd/terraform/variables.tf | 29 +-------------------- 6 files changed, 7 insertions(+), 48 deletions(-) diff --git a/cicd/devnet/terraform/main.tf b/cicd/devnet/terraform/main.tf index e7723398bf..fc998b799c 100644 --- a/cicd/devnet/terraform/main.tf +++ b/cicd/devnet/terraform/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "~> 5.13.1" } } } diff --git a/cicd/devnet/terraform/module/region/main.tf b/cicd/devnet/terraform/module/region/main.tf index 8e2ac0dd55..10fc5b08e6 100644 --- a/cicd/devnet/terraform/module/region/main.tf +++ b/cicd/devnet/terraform/module/region/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "~> 5.13.1" } } } diff --git a/cicd/devnet/terraform/s3.tf b/cicd/devnet/terraform/s3.tf index f04eeeb7d8..cd30e5ce32 100644 --- a/cicd/devnet/terraform/s3.tf +++ b/cicd/devnet/terraform/s3.tf @@ -1,4 +1,3 @@ -# Bucket need to be created first. If first time run terraform init, need to comment out the below section terraform { backend "s3" { bucket = "tf-xinfin-bucket" // This name need to be updated to be the same as local.s3BucketName. We can't use variable here. diff --git a/cicd/devnet/terraform/variables.tf b/cicd/devnet/terraform/variables.tf index 0d9b3bb125..12285d8ca7 100644 --- a/cicd/devnet/terraform/variables.tf +++ b/cicd/devnet/terraform/variables.tf @@ -5,15 +5,6 @@ variable docker_tag { } locals { - /** - Load the nodes data from s3 - Below is the the format the config needs to follow: - {{Name of the node, in a pattern of 'xdc'+ number. i.e xdc50}}: { - pk: {{Value of the node private key}}, - ... any other configuration we want to pass. - } - Note: No `n` is allowed in the node name - **/ predefinedNodesConfig = jsondecode(data.aws_s3_object.devnet_xdc_node_config.body) envs = { for tuple in regexall("(.*)=(.*)", file(".env")) : tuple[0] => tuple[1] } logLevel = local.envs["log_level"] @@ -37,12 +28,12 @@ locals { ] keyNames = { - for r in local.regions : + for r in local.regions : r.name => [for i in range(r.start, r.end+1) : "xdc${i}"] } devnetNodeKeys = { - for r in local.regions : + for r in local.regions : r.name => { for i in local.keyNames[r.name]: i => local.predefinedNodesConfig[i] } } } diff --git a/cicd/terraform/main.tf b/cicd/terraform/main.tf index e34f8c5ffe..7fc541fb7f 100644 --- a/cicd/terraform/main.tf +++ b/cicd/terraform/main.tf @@ -12,8 +12,6 @@ provider "aws" { region = "us-east-1" } -# WARNING: APSE-1 will only be used to host rpc node -# Workaround to avoid conflicts with existing ecs cluster in existing regions provider "aws" { alias = "ap-southeast-1" region = "ap-southeast-1" @@ -25,9 +23,9 @@ module "devnet_rpc" { vpc_id = local.vpc_id aws_subnet_id = local.aws_subnet_id ami_id = local.ami_id - instance_type = "t3.xlarge" + instance_type = "t3.large" ssh_key_name = local.ssh_key_name - rpc_image = local.rpc_image + rpc_image = local.rpc_image volume_size = 1500 providers = { @@ -43,7 +41,7 @@ module "testnet_rpc" { ami_id = local.ami_id instance_type = "t3.large" ssh_key_name = local.ssh_key_name - rpc_image = local.rpc_image + rpc_image = local.rpc_image volume_size = 1500 providers = { @@ -59,7 +57,7 @@ module "mainnet_rpc" { ami_id = local.ami_id instance_type = "t3.large" ssh_key_name = local.ssh_key_name - rpc_image = local.rpc_image + rpc_image = local.rpc_image volume_size = 3000 providers = { diff --git a/cicd/terraform/variables.tf b/cicd/terraform/variables.tf index c5a1eb8970..02bf5bdcf4 100644 --- a/cicd/terraform/variables.tf +++ b/cicd/terraform/variables.tf @@ -1,41 +1,14 @@ locals { - /** - Load the nodes data from s3 - Below is the the format the config needs to follow: - {{Name of the node, in a pattern of 'xdc'+ number. i.e xdc50}}: { - pk: {{Value of the node private key}}, - ... any other configuration we want to pass. - } - Note: No `n` is allowed in the node name - **/ predefinedNodesConfig = jsondecode(data.aws_s3_object.xdc_node_config.body) envs = { for tuple in regexall("(.*)=(.*)", file(".env")) : tuple[0] => tuple[1] } logLevel = local.envs["log_level"] - # regions = [ - # { - # "name": "us-east-2", // Ohio - # "start": local.envs["us_east_2_start"], - # "end": local.envs["us_east_2_end"], - # } - # ] - - # keyNames = { - # for r in local.regions : - # r.name => [for i in range(r.start, r.end+1) : "xdc${i}"] - # } - - # nodeKeys = { - # for r in local.regions : - # r.name => { for i in local.keyNames[r.name]: i => local.predefinedNodesConfig[i] } - # } - rpcDevnetNodeKeys = { "devnet-rpc1": local.predefinedNodesConfig["devnet-rpc1"]} // we hardcode the rpc to a single node for now rpcTestnetNodeKeys = { "testnet-rpc1": local.predefinedNodesConfig["testnet-rpc1"]} // we hardcode the rpc to a single node for now rpcMainnetNodeKeys = { "mainnet-rpc1": local.predefinedNodesConfig["mainnet-rpc1"]} // we hardcode the rpc to a single node for now } -locals { //ec2_rpc values +locals { ami_id = "ami-097c4e1feeea169e5" rpc_image = "xinfinorg/xdposchain:v2.2.0-beta1" vpc_id = "vpc-20a06846"