mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-21 14:14:30 +00:00
remove devnet ecs terraform (#786)
Co-authored-by: liam.lai <liam.lai@us>
This commit is contained in:
parent
6307460603
commit
ac3b44eebf
12 changed files with 10 additions and 668 deletions
78
.github/workflows/ci.yml
vendored
78
.github/workflows/ci.yml
vendored
|
|
@ -100,23 +100,6 @@ jobs:
|
|||
echo "image_name=$image_name"
|
||||
echo "image_name=$image_name" >> "$GITHUB_OUTPUT"
|
||||
|
||||
devnet_terraform_apply:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
needs: devnet_build_push
|
||||
environment: devnet
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Terraform Apply
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||
cd cicd/devnet/terraform
|
||||
terraform init ${{ env.tf_init_cli_options }}
|
||||
terraform apply -var "docker_tag=dev-upgrade-${git_hash}" ${{ env.tf_apply_cli_options }}
|
||||
|
||||
rpcnode_terraform_apply:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
|
|
@ -143,54 +126,13 @@ jobs:
|
|||
--extra-vars network=ec2_rpcs
|
||||
--extra-vars rpc_image=${{ needs.devnet_build_push.outputs.output1 }}
|
||||
|
||||
devnet_dev-upgrade_node:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
needs: rpcnode_terraform_apply
|
||||
environment: devnet
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: ECS Update
|
||||
run: |
|
||||
aws ecs update-service --region ap-southeast-1 --cluster devnet-xdcnode-cluster --service ecs-service-rpc1 --force-new-deployment --no-cli-pager | head -n 10;
|
||||
|
||||
testnet_dev-upgrade_node:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
needs: rpcnode_terraform_apply
|
||||
environment: testnet
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: ECS Update
|
||||
run: |
|
||||
aws ecs update-service --region ap-southeast-1 --cluster testnet-xdcnode-cluster --service ecs-service-testnet-rpc1 --force-new-deployment --no-cli-pager | head -n 10;
|
||||
|
||||
mainnet_dev-upgrade_node:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
needs: rpcnode_terraform_apply
|
||||
environment: mainnet
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: ECS Update
|
||||
run: |
|
||||
aws ecs update-service --region ap-southeast-1 --cluster mainnet-xdcnode-cluster --service ecs-service-mainnet-rpc1 --force-new-deployment --no-cli-pager | head -n 10;
|
||||
|
||||
devnet_send_notification:
|
||||
runs-on: ubuntu-latest
|
||||
needs: devnet_terraform_apply
|
||||
if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Send deployment notification
|
||||
run: |
|
||||
curl --location --request POST "66.94.98.186:8080/deploy?environment=devnet&service=xdc&version=${GITHUB_SHA}"
|
||||
# TODO Uncomment until new devnet
|
||||
# devnet_send_notification:
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: devnet_terraform_apply
|
||||
# if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/')
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - name: Send deployment notification
|
||||
# run: |
|
||||
# curl --location --request POST "66.94.98.186:8080/deploy?environment=devnet&service=xdc&version=${GITHUB_SHA}"
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
log_level=2
|
||||
|
||||
# Ohio
|
||||
us_east_2_start=11
|
||||
us_east_2_end=36
|
||||
|
||||
# Ireland
|
||||
eu_west_1_start=37
|
||||
eu_west_1_end=62
|
||||
|
||||
# Sydney
|
||||
ap_southeast_2_start=73
|
||||
ap_southeast_2_end=73
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# IAM policies
|
||||
data "aws_iam_policy_document" "xdc_ecs_tasks_execution_role" {
|
||||
statement {
|
||||
actions = ["sts:AssumeRole"]
|
||||
|
||||
principals {
|
||||
type = "Service"
|
||||
identifiers = ["ecs-tasks.amazonaws.com"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Create the role
|
||||
resource "aws_iam_role" "devnet_xdc_ecs_tasks_execution_role" {
|
||||
name = "devnet-xdc-ecs-task-execution-role"
|
||||
assume_role_policy = "${data.aws_iam_policy_document.xdc_ecs_tasks_execution_role.json}"
|
||||
}
|
||||
|
||||
# Attached the AWS managed policies to the new role
|
||||
resource "aws_iam_role_policy_attachment" "devnet_xdc_ecs_tasks_execution_role" {
|
||||
for_each = toset([
|
||||
"arn:aws:iam::aws:policy/AmazonElasticFileSystemClientFullAccess",
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy",
|
||||
"arn:aws:iam::aws:policy/AmazonElasticFileSystemsUtils"
|
||||
])
|
||||
role = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.name
|
||||
policy_arn = each.value
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Default
|
||||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
alias = "us-east-2"
|
||||
region = "us-east-2"
|
||||
}
|
||||
|
||||
module "us-east-2" {
|
||||
source = "./module/region"
|
||||
region = "us-east-2"
|
||||
devnetNodeKeys = local.devnetNodeKeys["us-east-2"]
|
||||
logLevel = local.logLevel
|
||||
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn
|
||||
docker_tag = var.docker_tag
|
||||
providers = {
|
||||
aws = aws.us-east-2
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
alias = "eu-west-1"
|
||||
region = "eu-west-1"
|
||||
}
|
||||
|
||||
module "eu-west-1" {
|
||||
source = "./module/region"
|
||||
region = "eu-west-1"
|
||||
devnetNodeKeys = local.devnetNodeKeys["eu-west-1"]
|
||||
logLevel = local.logLevel
|
||||
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn
|
||||
docker_tag = var.docker_tag
|
||||
providers = {
|
||||
aws = aws.eu-west-1
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
alias = "ap-southeast-2"
|
||||
region = "ap-southeast-2"
|
||||
}
|
||||
|
||||
module "ap-southeast-2" {
|
||||
source = "./module/region"
|
||||
region = "ap-southeast-2"
|
||||
devnetNodeKeys = local.devnetNodeKeys["ap-southeast-2"]
|
||||
logLevel = local.logLevel
|
||||
devnet_xdc_ecs_tasks_execution_role_arn = aws_iam_role.devnet_xdc_ecs_tasks_execution_role.arn
|
||||
docker_tag = var.docker_tag
|
||||
providers = {
|
||||
aws = aws.ap-southeast-2
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
[
|
||||
{
|
||||
"name": "tfXdcNode",
|
||||
"image": "xinfinorg/${image_environment}:${image_tag}",
|
||||
"environment": [
|
||||
{"name": "PRIVATE_KEY", "value": "${private_key}"},
|
||||
{"name": "LOG_LEVEL", "value": "${log_level}"},
|
||||
{"name": "NODE_NAME", "value": "${node_name}"},
|
||||
{"name": "NETWORK", "value": "${chain_network}"}
|
||||
],
|
||||
"essential": true,
|
||||
"logConfiguration": {
|
||||
"logDriver": "awslogs",
|
||||
"options": {
|
||||
"awslogs-group": "${cloudwatch_group}",
|
||||
"awslogs-region": "${cloudwatch_region}",
|
||||
"awslogs-stream-prefix": "ecs"
|
||||
}
|
||||
},
|
||||
"portMappings": [
|
||||
{
|
||||
"hostPort": 8555,
|
||||
"protocol": "tcp",
|
||||
"containerPort": 8555
|
||||
},
|
||||
{
|
||||
"hostPort": 8545,
|
||||
"protocol": "tcp",
|
||||
"containerPort": 8545
|
||||
},
|
||||
{
|
||||
"hostPort": 30303,
|
||||
"protocol": "tcp",
|
||||
"containerPort": 30303
|
||||
}
|
||||
],
|
||||
"mountPoints": [
|
||||
{
|
||||
"containerPath": "/work/xdcchain",
|
||||
"sourceVolume": "efs"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
data template_file devnet_container_definition {
|
||||
for_each = var.devnetNodeKeys
|
||||
template = "${file("${path.module}/container-definition.tpl")}"
|
||||
|
||||
vars = {
|
||||
image_environment = "${lookup(each.value, "imageEnvironment", "devnet")}"
|
||||
image_tag = "${lookup(each.value, "imageTag", var.docker_tag)}"
|
||||
node_name = "${each.key}"
|
||||
private_key = "${each.value.pk}"
|
||||
cloudwatch_group = "tf-${each.key}"
|
||||
cloudwatch_region = "${var.region}"
|
||||
log_level = "${lookup(each.value, "logLevel", "${var.logLevel}")}"
|
||||
chain_network = "devnet"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_ecs_task_definition" "devnet_task_definition_group" {
|
||||
for_each = var.devnetNodeKeys
|
||||
|
||||
family = "devnet-${each.key}"
|
||||
requires_compatibilities = ["FARGATE"]
|
||||
network_mode = "awsvpc"
|
||||
container_definitions = data.template_file.devnet_container_definition[each.key].rendered
|
||||
execution_role_arn = var.devnet_xdc_ecs_tasks_execution_role_arn
|
||||
task_role_arn = var.devnet_xdc_ecs_tasks_execution_role_arn
|
||||
|
||||
# New nodes will consume a lot more CPU usage than existing nodes.
|
||||
# This is due to sync is resource heavy. Recommending set to below if doing sync:
|
||||
# CPU = 2048, Memory = 4096
|
||||
# Please set it back to cpu 256 and memory of 2048 after sync is done to save the cost
|
||||
# cpu = 256
|
||||
# memory = 2048
|
||||
cpu = 1024
|
||||
memory = 4096
|
||||
volume {
|
||||
name = "efs"
|
||||
|
||||
efs_volume_configuration {
|
||||
file_system_id = aws_efs_file_system.devnet_efs[each.key].id
|
||||
root_directory = "/"
|
||||
transit_encryption = "ENABLED"
|
||||
authorization_config {
|
||||
access_point_id = aws_efs_access_point.devnet_efs_access_point[each.key].id
|
||||
iam = "DISABLED"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetEcs-${each.key}"
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_ecs_task_definition" "devnet_ecs_task_definition" {
|
||||
for_each = var.devnetNodeKeys
|
||||
task_definition = aws_ecs_task_definition.devnet_task_definition_group[each.key].family
|
||||
}
|
||||
|
||||
# ECS cluster
|
||||
resource "aws_ecs_cluster" "devnet_ecs_cluster" {
|
||||
name = "devnet-xdcnode-cluster"
|
||||
tags = {
|
||||
Name = "TfDevnetEcsCluster"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resource "aws_ecs_service" "devnet_ecs_service" {
|
||||
for_each = var.enableFixedIp ? {} : var.devnetNodeKeys
|
||||
name = "ecs-service-${each.key}"
|
||||
cluster = aws_ecs_cluster.devnet_ecs_cluster.id
|
||||
task_definition = "${aws_ecs_task_definition.devnet_task_definition_group[each.key].family}:${max(aws_ecs_task_definition.devnet_task_definition_group[each.key].revision, data.aws_ecs_task_definition.devnet_ecs_task_definition[each.key].revision)}"
|
||||
launch_type = "FARGATE"
|
||||
scheduling_strategy = "REPLICA"
|
||||
desired_count = 1
|
||||
force_new_deployment = true
|
||||
deployment_minimum_healthy_percent = 0
|
||||
deployment_maximum_percent = 100
|
||||
|
||||
network_configuration {
|
||||
subnets = [aws_subnet.devnet_subnet.id]
|
||||
assign_public_ip = true
|
||||
security_groups = [
|
||||
aws_default_security_group.devnet_xdcnode_security_group.id
|
||||
]
|
||||
}
|
||||
|
||||
deployment_circuit_breaker {
|
||||
enable = true
|
||||
rollback = false
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetEcsService-${each.key}"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
|
||||
# EFS
|
||||
resource "aws_security_group" "devnet_efs_security_group" {
|
||||
name = "TfDevnetEfsSecurityGroup"
|
||||
description = "Allow HTTP in and out of devnet EFS"
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
|
||||
ingress {
|
||||
from_port = 2049
|
||||
to_port = 2049
|
||||
protocol = "TCP"
|
||||
security_groups = [aws_default_security_group.devnet_xdcnode_security_group.id]
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
tags = {
|
||||
Name = "TfDevnetEfs"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_efs_file_system" "devnet_efs" {
|
||||
for_each = var.devnetNodeKeys
|
||||
creation_token = "efs-${each.key}"
|
||||
performance_mode = "generalPurpose"
|
||||
throughput_mode = "bursting"
|
||||
encrypted = "true"
|
||||
lifecycle_policy {
|
||||
transition_to_ia = "AFTER_30_DAYS"
|
||||
}
|
||||
tags = {
|
||||
Name = "TfDevnetEfs${each.key}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_efs_mount_target" "devnet_efs_efs_mount_target" {
|
||||
for_each = var.devnetNodeKeys
|
||||
file_system_id = aws_efs_file_system.devnet_efs[each.key].id
|
||||
subnet_id = aws_subnet.devnet_subnet.id
|
||||
security_groups = [aws_security_group.devnet_efs_security_group.id]
|
||||
}
|
||||
|
||||
resource "aws_efs_access_point" "devnet_efs_access_point" {
|
||||
for_each = var.devnetNodeKeys
|
||||
file_system_id = aws_efs_file_system.devnet_efs[each.key].id
|
||||
root_directory {
|
||||
path = "/${each.key}/database"
|
||||
creation_info {
|
||||
owner_gid = 1001
|
||||
owner_uid = 1001
|
||||
permissions = 777
|
||||
}
|
||||
}
|
||||
posix_user {
|
||||
gid = 1001
|
||||
uid = 1001
|
||||
secondary_gids = [0]
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetEfsAccessPoint${each.key}"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_vpc" "devnet_vpc" {
|
||||
cidr_block = "10.0.0.0/16"
|
||||
instance_tenancy = "default"
|
||||
enable_dns_hostnames = true
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetVpc"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "devnet_subnet" {
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
cidr_block = "10.0.0.0/20"
|
||||
map_public_ip_on_launch = true
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetVpcSubnet"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_internet_gateway" "devnet_gatewat" {
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetGateway"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table" "devnet_route_table" {
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
|
||||
route {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.devnet_gatewat.id
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetVpcRoutingTable"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "devnet_route_table_association" {
|
||||
subnet_id = aws_subnet.devnet_subnet.id
|
||||
route_table_id = aws_route_table.devnet_route_table.id
|
||||
}
|
||||
|
||||
resource "aws_default_security_group" "devnet_xdcnode_security_group" {
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
|
||||
ingress {
|
||||
description = "listener port"
|
||||
from_port = 30303
|
||||
to_port = 30303
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
ingress {
|
||||
description = "discovery port"
|
||||
from_port = 30303
|
||||
to_port = 30303
|
||||
protocol = "udp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
ingress {
|
||||
description = "rpc port"
|
||||
from_port = 8545
|
||||
to_port = 8545
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["10.0.0.0/16"]
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
tags = {
|
||||
Name = "TfDevnetNode"
|
||||
}
|
||||
}
|
||||
|
||||
# Logs
|
||||
resource "aws_cloudwatch_log_group" "devnet_cloud_watch_group" {
|
||||
for_each = var.devnetNodeKeys
|
||||
|
||||
name = "tf-${each.key}"
|
||||
retention_in_days = 14 # Logs are only kept for 14 days
|
||||
tags = {
|
||||
Name = "TfDevnetCloudWatchGroup${each.key}"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
# Allocate an Elastic IP for the NLB
|
||||
resource "aws_eip" "nlb_eip" {
|
||||
domain = "vpc"
|
||||
}
|
||||
|
||||
|
||||
# Create a Network Load Balancer
|
||||
resource "aws_lb" "rpc_node_nlb" {
|
||||
count = var.enableFixedIp ? 1 : 0
|
||||
name = "rpc-node-nlb"
|
||||
load_balancer_type = "network"
|
||||
|
||||
enable_deletion_protection = false
|
||||
|
||||
subnet_mapping {
|
||||
subnet_id = aws_subnet.devnet_subnet.id
|
||||
allocation_id = aws_eip.nlb_eip.id
|
||||
}
|
||||
}
|
||||
|
||||
# Listener and Target Group for the rpc node container
|
||||
resource "aws_lb_target_group" "rpc_node_tg_8545" {
|
||||
count = var.enableFixedIp ? 1 : 0
|
||||
name = "rpc-node-tg"
|
||||
port = 8545
|
||||
protocol = "TCP"
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
target_type = "ip"
|
||||
}
|
||||
|
||||
resource "aws_lb_listener" "rpc_node_listener_8545" {
|
||||
count = var.enableFixedIp ? 1 : 0
|
||||
load_balancer_arn = aws_lb.rpc_node_nlb[0].arn
|
||||
port = 8545
|
||||
protocol = "TCP"
|
||||
|
||||
default_action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.rpc_node_tg_8545[0].arn
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "devnet_rpc_node_ecs_service" {
|
||||
for_each = var.enableFixedIp ? var.devnetNodeKeys : {}
|
||||
name = "ecs-service-${each.key}"
|
||||
cluster = aws_ecs_cluster.devnet_ecs_cluster.id
|
||||
task_definition = "${aws_ecs_task_definition.devnet_task_definition_group[each.key].family}:${max(aws_ecs_task_definition.devnet_task_definition_group[each.key].revision, data.aws_ecs_task_definition.devnet_ecs_task_definition[each.key].revision)}"
|
||||
launch_type = "FARGATE"
|
||||
scheduling_strategy = "REPLICA"
|
||||
desired_count = 1
|
||||
force_new_deployment = true
|
||||
deployment_minimum_healthy_percent = 0
|
||||
deployment_maximum_percent = 100
|
||||
|
||||
network_configuration {
|
||||
subnets = [aws_subnet.devnet_subnet.id]
|
||||
assign_public_ip = true
|
||||
security_groups = [
|
||||
aws_default_security_group.devnet_xdcnode_security_group.id
|
||||
]
|
||||
}
|
||||
|
||||
deployment_circuit_breaker {
|
||||
enable = true
|
||||
rollback = false
|
||||
}
|
||||
|
||||
load_balancer {
|
||||
target_group_arn = aws_lb_target_group.rpc_node_tg_8545[0].arn
|
||||
container_name = "tfXdcNode"
|
||||
container_port = 8545
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
aws_lb_listener.rpc_node_listener_8545
|
||||
]
|
||||
|
||||
tags = {
|
||||
Name = "TfDevnetRpcNodeEcsService-${each.key}"
|
||||
}
|
||||
}
|
||||
|
||||
# Target Group for port 30303
|
||||
resource "aws_lb_target_group" "rpc_node_tg_30303" {
|
||||
count = var.enableFixedIp ? 1 : 0
|
||||
name = "rpc-node-tg-30303"
|
||||
port = 30303
|
||||
protocol = "TCP"
|
||||
vpc_id = aws_vpc.devnet_vpc.id
|
||||
target_type = "ip"
|
||||
}
|
||||
|
||||
# Listener for port 30303
|
||||
resource "aws_lb_listener" "rpc_node_listener_30303" {
|
||||
count = var.enableFixedIp ? 1 : 0
|
||||
load_balancer_arn = aws_lb.rpc_node_nlb[0].arn
|
||||
port = 30303
|
||||
protocol = "TCP"
|
||||
|
||||
default_action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.rpc_node_tg_30303[0].arn
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
variable "region" {
|
||||
description = "AWS region"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "devnetNodeKeys" {
|
||||
description = "each miner's key"
|
||||
type = map
|
||||
}
|
||||
|
||||
variable "logLevel" {
|
||||
description = "containers log level"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "devnet_xdc_ecs_tasks_execution_role_arn" {
|
||||
description = "aws iam role resource arn"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "enableFixedIp" {
|
||||
description = "a flag to indicate whether fixed ip should be associated to the nodes. This is used for RPC node"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable docker_tag {
|
||||
type = string
|
||||
default = "latest"
|
||||
description = "description"
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
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.
|
||||
key = "tf/terraform_devnet.tfstate"
|
||||
region = "us-east-1"
|
||||
encrypt = true
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_s3_object" "devnet_xdc_node_config" {
|
||||
bucket = "tf-xinfin-bucket"
|
||||
key = "node-config.json"
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
variable docker_tag {
|
||||
type = string
|
||||
default = "latest"
|
||||
description = "description"
|
||||
}
|
||||
|
||||
locals {
|
||||
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"]
|
||||
|
||||
regions = [
|
||||
{
|
||||
"name": "us-east-2", // Ohio
|
||||
"start": local.envs["us_east_2_start"],
|
||||
"end": local.envs["us_east_2_end"],
|
||||
},
|
||||
{
|
||||
"name": "eu-west-1", // Ireland
|
||||
"start": local.envs["eu_west_1_start"],
|
||||
"end": local.envs["eu_west_1_end"],
|
||||
},
|
||||
{
|
||||
"name": "ap-southeast-2", // Sydney
|
||||
"start": local.envs["ap_southeast_2_start"],
|
||||
"end": local.envs["ap_southeast_2_end"],
|
||||
}
|
||||
]
|
||||
|
||||
keyNames = {
|
||||
for r in local.regions :
|
||||
r.name => [for i in range(r.start, r.end+1) : "xdc${i}"]
|
||||
}
|
||||
|
||||
devnetNodeKeys = {
|
||||
for r in local.regions :
|
||||
r.name => { for i in local.keyNames[r.name]: i => local.predefinedNodesConfig[i] }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue