Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
improve ec2 instance naming
Browse files Browse the repository at this point in the history
  • Loading branch information
corverroos committed Oct 13, 2023
1 parent 58f7eb2 commit 2224f3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ module "ec2_database" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "4.2.1"
count = var.deploy_ec2_instance_db ? 1 : 0
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-db-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-db"
ami = data.aws_ami.ubuntu.id
instance_type = "t2.medium"
monitoring = false
Expand Down Expand Up @@ -226,7 +226,7 @@ module "ec2_asg_indexer" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-indexer-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-indexer"
min_size = 1
max_size = 1
vpc_zone_identifier = var.existed_vpc_id != "" ? slice(var.existed_private_subnets_ids, 0, 1) : slice(module.vpc[0].private_subnets, 0, 1)
Expand Down Expand Up @@ -271,7 +271,7 @@ module "ec2_asg_api_and_ui" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-api-and-ui-instances"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-api-and-ui"
min_size = length(var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets)
max_size = length(var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets)
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down Expand Up @@ -317,7 +317,7 @@ module "ec2_asg_verifier" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-verifier-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-verifier"
min_size = var.verifier_replicas
max_size = var.verifier_replicas
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down Expand Up @@ -352,7 +352,7 @@ module "ec2_asg_visualizer" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-visualizer-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-visualizer"
min_size = var.visualizer_replicas
max_size = var.visualizer_replicas
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down Expand Up @@ -382,7 +382,7 @@ module "ec2_asg_sig_provider" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-sig-provider-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-sig-provider"
min_size = var.sig_provider_replicas
max_size = var.sig_provider_replicas
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down Expand Up @@ -412,7 +412,7 @@ module "ec2_asg_stats" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-stats-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-stats"
min_size = var.stats_replicas
max_size = var.stats_replicas
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down Expand Up @@ -446,7 +446,7 @@ module "ec2_asg_eth_bytecode_db" {
source = "./asg"
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-eth-bytecode-db-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-eth-bytecode-db"
min_size = var.eth_bytecode_db_replicas
max_size = var.eth_bytecode_db_replicas
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down Expand Up @@ -481,7 +481,7 @@ module "ec2_asg_xchain_indexer" {
block_devices = var.block_devices
count = var.xchain_settings["enabled"] ? 1 : 0
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-xchain-indexer-instance"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-xchain-indexer"
min_size = 1
max_size = 1
vpc_zone_identifier = var.existed_vpc_id != "" ? slice(var.existed_private_subnets_ids, 0, 1) : slice(module.vpc[0].private_subnets, 0, 1)
Expand Down Expand Up @@ -518,7 +518,7 @@ module "ec2_asg_xchain_api" {
count = var.xchain_settings["enabled"] ? 1 : 0
block_devices = var.block_devices
## ASG settings
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-asg-xchain-api-instances"
name = "${var.vpc_name != "" ? var.vpc_name : "existed-vpc"}-xchain-api"
min_size = length(var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets)
max_size = length(var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets)
vpc_zone_identifier = var.existed_vpc_id != "" ? var.existed_private_subnets_ids : module.vpc[0].private_subnets
Expand Down
20 changes: 10 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ locals {
EOF
}

module "obs_staging_vpc" {
module "staging_vpc" {
source = "./aws"
count = var.deploy_staging_blockscout ? 1 : 0
vpc_name = "obs-staging"
vpc_name = "staging"
vpc_cidr = "10.104.0.0/16"
ssl_certificate_arn = var.ssl_certificate_arn
create_iam_instance_profile_ssm_policy = "true"
Expand Down Expand Up @@ -147,10 +147,10 @@ module "obs_staging_vpc" {
]
}

module "obs_testnet_vpc" {
module "testnet_vpc" {
source = "./aws"
count = var.deploy_testnet_blockscout ? 1 : 0
vpc_name = "obs-testnet"
vpc_name = "testnet"
vpc_cidr = "10.105.0.0/16"
ssl_certificate_arn = var.ssl_certificate_arn
create_iam_instance_profile_ssm_policy = "true"
Expand Down Expand Up @@ -202,7 +202,7 @@ resource "cloudflare_record" "staging_cname" {
type = "CNAME"
proxied = false
count = var.deploy_staging_blockscout ? 1 : 0
value = var.deploy_staging_blockscout ? module.obs_staging_vpc[0].blockscout_url : null
value = var.deploy_staging_blockscout ? module.staging_vpc[0].blockscout_url : null
allow_overwrite = true
}

Expand All @@ -212,7 +212,7 @@ resource "cloudflare_record" "testnet_cname" {
type = "CNAME"
proxied = false
count = var.deploy_testnet_blockscout ? 1 : 0
value = var.deploy_testnet_blockscout ? module.obs_testnet_vpc[0].blockscout_url : null
value = var.deploy_testnet_blockscout ? module.testnet_vpc[0].blockscout_url : null
allow_overwrite = true
}

Expand All @@ -222,7 +222,7 @@ resource "cloudflare_record" "staging_xchain_cname" {
type = "CNAME"
proxied = false
count = var.deploy_staging_blockscout ? 1 : 0
value = var.deploy_staging_blockscout ? module.obs_staging_vpc[0].xchain_url : null
value = var.deploy_staging_blockscout ? module.staging_vpc[0].xchain_url : null
allow_overwrite = true
}

Expand All @@ -232,14 +232,14 @@ resource "cloudflare_record" "testnet_xchain_cname" {
type = "CNAME"
proxied = false
count = var.deploy_testnet_blockscout ? 1 : 0
value = var.deploy_testnet_blockscout ? module.obs_testnet_vpc[0].xchain_url : null
value = var.deploy_testnet_blockscout ? module.testnet_vpc[0].xchain_url : null
allow_overwrite = true
}

output "staging_blockscout_url" {
value = var.deploy_staging_blockscout ? module.obs_staging_vpc[0].blockscout_url : null
value = var.deploy_staging_blockscout ? module.staging_vpc[0].blockscout_url : null
}

output "testnet_blockscout_url" {
value = var.deploy_testnet_blockscout ? module.obs_testnet_vpc[0].blockscout_url : null
value = var.deploy_testnet_blockscout ? module.testnet_vpc[0].blockscout_url : null
}

0 comments on commit 2224f3a

Please sign in to comment.