From 0b0c8de52f148a06475a992cf7b7e122f9e72069 Mon Sep 17 00:00:00 2001 From: kris20030907 <3185633428@qq.com> Date: Tue, 20 Aug 2024 11:13:17 +0800 Subject: [PATCH 1/3] refactor: Change the label --- aws.tf | 217 ++++++++++++++++ main.tf | 240 +----------------- .../automq_byoc_role_policy.json.tpl | 0 tpls/userdata.tpl | 13 + 4 files changed, 243 insertions(+), 227 deletions(-) create mode 100644 aws.tf rename automq_byoc_role_policy.json.tpl => tpls/automq_byoc_role_policy.json.tpl (100%) create mode 100644 tpls/userdata.tpl diff --git a/aws.tf b/aws.tf new file mode 100644 index 0000000..19feb4d --- /dev/null +++ b/aws.tf @@ -0,0 +1,217 @@ +provider "aws" { + region = var.cloud_provider_region +} + +# Conditional creation of data bucket +module "automq_byoc_data_bucket_name" { + source = "terraform-aws-modules/s3-bucket/aws" + version = "4.1.2" + + create_bucket = var.automq_byoc_data_bucket_name == "" ? true : false + bucket = "automq-data-${var.automq_byoc_env_id}" + force_destroy = true +} + +# Conditional creation of ops bucket +module "automq_byoc_ops_bucket_name" { + source = "terraform-aws-modules/s3-bucket/aws" + version = "4.1.2" + + create_bucket = var.automq_byoc_ops_bucket_name == "" ? true : false + bucket = "automq-ops-${var.automq_byoc_env_id}" + force_destroy = true +} + +data "aws_availability_zones" "available" {} + +module "automq_byoc_vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "5.0.0" + + count = var.create_new_vpc ? 1 : 0 + + name = "automq-byoc-vpc-${var.automq_byoc_env_id}" + cidr = "10.0.0.0/16" + + azs = slice(data.aws_availability_zones.available.names, 0, 3) + public_subnets = ["10.0.0.0/20"] + private_subnets = ["10.0.128.0/20", "10.0.144.0/20", "10.0.160.0/20"] + + enable_dns_support = true + enable_dns_hostnames = true + + tags = { + + automqVendor = "automq" + automqEnvironmentID = var.automq_byoc_env_id + } +} + +resource "aws_security_group" "endpoint_sg" { + count = var.create_new_vpc ? 1 : 0 + + name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}" + description = "Security group for VPC endpoint" + vpc_id = module.automq_byoc_vpc[0].vpc_id + + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}" + automqVendor = "automq" + automqEnvironmentID = var.automq_byoc_env_id + } +} + +resource "aws_vpc_endpoint" "ec2" { + count = var.create_new_vpc ? 1 : 0 + + vpc_id = module.automq_byoc_vpc[0].vpc_id + service_name = "com.amazonaws.${var.cloud_provider_region}.ec2" + vpc_endpoint_type = "Interface" + security_group_ids = [aws_security_group.endpoint_sg[0].id] + subnet_ids = module.automq_byoc_vpc[0].private_subnets + + private_dns_enabled = true + + tags = { + Name = "automq-byoc-ec2-endpoint-${var.automq_byoc_env_id}" + automqVendor = "automq" + automqEnvironmentID = var.automq_byoc_env_id + } +} + +resource "aws_vpc_endpoint" "s3" { + count = var.create_new_vpc ? 1 : 0 + + vpc_id = module.automq_byoc_vpc[0].vpc_id + service_name = "com.amazonaws.${var.cloud_provider_region}.s3" + vpc_endpoint_type = "Gateway" + + route_table_ids = concat( + module.automq_byoc_vpc[0].public_route_table_ids, + module.automq_byoc_vpc[0].private_route_table_ids + ) + + tags = { + Name = "automq-byoc-s3-endpoint-${var.automq_byoc_env_id}" + automqVendor = "automq" + automqEnvironmentID = var.automq_byoc_env_id + } +} + +locals { + automq_byoc_vpc_id = var.create_new_vpc ? module.automq_byoc_vpc[0].vpc_id : var.automq_byoc_vpc_id + automq_byoc_env_console_public_subnet_id = var.create_new_vpc ? element(module.automq_byoc_vpc[0].public_subnets, 0) : var.automq_byoc_env_console_public_subnet_id + automq_data_bucket = var.automq_byoc_data_bucket_name == "" ? module.automq_byoc_data_bucket_name.s3_bucket_id : "${var.automq_byoc_data_bucket_name}-${var.automq_byoc_env_id}" + automq_ops_bucket = var.automq_byoc_ops_bucket_name == "" ? module.automq_byoc_ops_bucket_name.s3_bucket_id : "${var.automq_byoc_ops_bucket_name}-${var.automq_byoc_env_id}" +} + +data "aws_vpc" "selected" { + id = local.automq_byoc_vpc_id +} + +locals { + ssm_parameter_path = "/aws/service/marketplace/prod-nl2cyzygb46fw/${var.automq_byoc_env_version}" +} + +data "aws_ssm_parameter" "marketplace_ami" { + name = local.ssm_parameter_path +} + +data "aws_ami" "marketplace_ami_details" { + most_recent = true + + filter { + name = "image-id" + values = [data.aws_ssm_parameter.marketplace_ami.value] + } +} + +resource "aws_security_group" "allow_all" { + vpc_id = data.aws_vpc.selected.id + + ingress { + from_port = 8080 + to_port = 8080 + protocol = "tcp" + cidr_blocks = [var.automq_byoc_env_console_cidr] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_iam_role" "automq_byoc_role" { + name = "automq-byoc-service-role-${var.automq_byoc_env_id}" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Sid = "" + Principal = { + Service = "ec2.amazonaws.com" + } + }, + ] + }) +} + +resource "aws_iam_policy" "automq_byoc_policy" { + name = "automq-byoc-service-policy-${var.automq_byoc_env_id}" + description = "Custom policy for automq_byoc service" + + policy = templatefile("${path.module}/tpls/automq_byoc_role_policy.json.tpl", { + automq_data_bucket = local.automq_data_bucket + automq_ops_bucket = local.automq_ops_bucket + }) +} + +resource "aws_iam_role_policy_attachment" "automq_byoc_role_attachment" { + role = aws_iam_role.automq_byoc_role.name + policy_arn = aws_iam_policy.automq_byoc_policy.arn +} + +resource "aws_iam_instance_profile" "automq_byoc_instance_profile" { + name = "automq-byoc-instance-profile-${var.automq_byoc_env_id}" + role = aws_iam_role.automq_byoc_role.name +} + +resource "aws_route53_zone" "private" { + name = "${var.automq_byoc_env_id}.automq.private" + + vpc { + vpc_id = local.automq_byoc_vpc_id + } + + lifecycle { + create_before_destroy = true + } +} + +locals { + aws_iam_instance_profile_arn_encoded = urlencode(aws_iam_instance_profile.automq_byoc_instance_profile.arn) +} + +resource "aws_eip" "web_ip" { + instance = aws_instance.web.id +} \ No newline at end of file diff --git a/main.tf b/main.tf index f760087..59bfa17 100644 --- a/main.tf +++ b/main.tf @@ -1,196 +1,3 @@ -provider "aws" { - region = var.cloud_provider_region -} - -# Conditional creation of data bucket -module "automq_byoc_data_bucket_name" { - source = "terraform-aws-modules/s3-bucket/aws" - version = "4.1.2" - - # If you don't specify a data-bucket, it will be created, otherwise the available bucket provided will be used - create_bucket = var.automq_byoc_data_bucket_name == "" ? true : false - bucket = "automq-data-${var.automq_byoc_env_id}" - force_destroy = true -} - -# Conditional creation of ops bucket -module "automq_byoc_ops_bucket_name" { - source = "terraform-aws-modules/s3-bucket/aws" - version = "4.1.2" - - create_bucket = var.automq_byoc_ops_bucket_name == "" ? true : false - bucket = "automq-ops-${var.automq_byoc_env_id}" - force_destroy = true -} - -data "aws_availability_zones" "available" {} - -module "automq_byoc_vpc" { - source = "terraform-aws-modules/vpc/aws" - version = "5.0.0" - - count = var.create_new_vpc ? 1 : 0 - - name = "automq-byoc-vpc-${var.automq_byoc_env_id}" - cidr = "10.0.0.0/16" - - azs = slice(data.aws_availability_zones.available.names, 0, 3) - public_subnets = ["10.0.0.0/20"] - private_subnets = ["10.0.128.0/20", "10.0.144.0/20", "10.0.160.0/20"] - - enable_dns_support = true - enable_dns_hostnames = true - - # 标签统一 - tags = { - Terraform = "true" - Environment = "dev" - } -} - -resource "aws_security_group" "endpoint_sg" { - count = var.create_new_vpc ? 1 : 0 - - name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}" - description = "Security group for VPC endpoint" - vpc_id = module.automq_byoc_vpc[0].vpc_id - - ingress { - from_port = 443 - to_port = 443 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - tags = { - Name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}" - } -} - -resource "aws_vpc_endpoint" "ec2" { - count = var.create_new_vpc ? 1 : 0 - - vpc_id = module.automq_byoc_vpc[0].vpc_id - service_name = "com.amazonaws.${var.cloud_provider_region}.ec2" - vpc_endpoint_type = "Interface" - security_group_ids = [aws_security_group.endpoint_sg[0].id] - subnet_ids = module.automq_byoc_vpc[0].private_subnets - - private_dns_enabled = true - - tags = { - Name = "automq-byoc-ec2-endpoint-${var.automq_byoc_env_id}" - } -} - -resource "aws_vpc_endpoint" "s3" { - count = var.create_new_vpc ? 1 : 0 - - vpc_id = module.automq_byoc_vpc[0].vpc_id - service_name = "com.amazonaws.${var.cloud_provider_region}.s3" - vpc_endpoint_type = "Gateway" - - route_table_ids = concat( - module.automq_byoc_vpc[0].public_route_table_ids, - module.automq_byoc_vpc[0].private_route_table_ids - ) - - tags = { - Name = "automq-byoc-s3-endpoint-${var.automq_byoc_env_id}" - } -} - -locals { - automq_byoc_vpc_id = var.create_new_vpc ? module.automq_byoc_vpc[0].vpc_id : var.automq_byoc_vpc_id - automq_byoc_env_console_public_subnet_id = var.create_new_vpc ? element(module.automq_byoc_vpc[0].public_subnets, 0) : var.automq_byoc_env_console_public_subnet_id - automq_data_bucket = var.automq_byoc_data_bucket_name == "" ? module.automq_byoc_data_bucket_name.s3_bucket_id : "${var.automq_byoc_data_bucket_name}-${var.automq_byoc_env_id}" - automq_ops_bucket = var.automq_byoc_ops_bucket_name == "" ? module.automq_byoc_ops_bucket_name.s3_bucket_id : "${var.automq_byoc_ops_bucket_name}-${var.automq_byoc_env_id}" -} - -data "aws_vpc" "selected" { - id = local.automq_byoc_vpc_id -} - -locals { - ssm_parameter_path = "/aws/service/marketplace/prod-nl2cyzygb46fw/${var.automq_byoc_env_version}" -} - -data "aws_ssm_parameter" "marketplace_ami" { - name = local.ssm_parameter_path -} - -data "aws_ami" "marketplace_ami_details" { - most_recent = true - - filter { - name = "image-id" - values = [data.aws_ssm_parameter.marketplace_ami.value] - } -} - -resource "aws_security_group" "allow_all" { - vpc_id = data.aws_vpc.selected.id - - ingress { - from_port = 8080 - to_port = 8080 - protocol = "tcp" - cidr_blocks = [var.automq_byoc_env_console_cidr] - } - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} - -resource "aws_iam_role" "automq_byoc_role" { - name = "automq-byoc-service-role-${var.automq_byoc_env_id}" - - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "ec2.amazonaws.com" - } - }, - ] - }) -} - -resource "aws_iam_policy" "automq_byoc_policy" { - name = "automq-byoc-service-policy-${var.automq_byoc_env_id}" - description = "Custom policy for automq_byoc service" - - policy = templatefile("${path.module}/automq_byoc_role_policy.json.tpl", { - automq_data_bucket = local.automq_data_bucket - automq_ops_bucket = local.automq_ops_bucket - }) -} - -resource "aws_iam_role_policy_attachment" "automq_byoc_role_attachment" { - role = aws_iam_role.automq_byoc_role.name - policy_arn = aws_iam_policy.automq_byoc_policy.arn -} - -resource "aws_iam_instance_profile" "automq_byoc_instance_profile" { - name = "automq-byoc-instance-profile-${var.automq_byoc_env_id}" - role = aws_iam_role.automq_byoc_role.name -} - resource "aws_instance" "web" { ami = var.specified_ami_by_marketplace ? data.aws_ami.marketplace_ami_details.id : var.automq_byoc_env_console_ami instance_type = var.automq_byoc_ec2_instance_type @@ -212,41 +19,20 @@ resource "aws_instance" "web" { tags = { Name = "automq-byoc-console-${var.automq_byoc_env_id}" + automqVendor = "automq" + automqEnvironmentID = var.automq_byoc_env_id } - user_data = <<-EOF - #cloud-config - bootcmd: - - | - if [ ! -f "/home/admin/config.properties" ]; then - touch /home/admin/config.properties - echo "cmp.provider.credential=vm-role://${local.aws_iam_instance_profile_arn_encoded}@aws" >> /home/admin/config.properties - echo 'cmp.provider.databucket=${local.automq_data_bucket}' >> /home/admin/config.properties - echo 'cmp.provider.opsBucket=${local.automq_ops_bucket}' >> /home/admin/config.properties - echo 'cmp.provider.instanceSecurityGroup=${aws_security_group.allow_all.id}' >> /home/admin/config.properties - echo 'cmp.provider.instanceDNS=${aws_route53_zone.private.zone_id}' >> /home/admin/config.properties - echo 'cmp.provider.instanceProfile=${aws_iam_instance_profile.automq_byoc_instance_profile.arn}' >> /home/admin/config.properties - echo 'cmp.environmentId=${var.automq_byoc_env_id}' >> /home/admin/config.properties - fi - EOF -} + associate_public_ip_address = true -resource "aws_route53_zone" "private" { - name = "${var.automq_byoc_env_id}.automq.private" - - vpc { - vpc_id = local.automq_byoc_vpc_id - } - - lifecycle { - create_before_destroy = true - } -} - -resource "aws_eip" "web_ip" { - instance = aws_instance.web.id -} - -locals { - aws_iam_instance_profile_arn_encoded = urlencode(aws_iam_instance_profile.automq_byoc_instance_profile.arn) + # Initialize the AutoMQ BYOC console configuration + user_data = templatefile("${path.module}/tpls/userdata.tpl", { + aws_iam_instance_profile_arn_encoded = local.aws_iam_instance_profile_arn_encoded, + automq_data_bucket = local.automq_data_bucket, + automq_ops_bucket = local.automq_ops_bucket, + instance_security_group_id = aws_security_group.allow_all.id, + instance_dns = aws_route53_zone.private.zone_id, + instance_profile_arn = aws_iam_instance_profile.automq_byoc_instance_profile.arn, + environment_id = var.automq_byoc_env_id + }) } \ No newline at end of file diff --git a/automq_byoc_role_policy.json.tpl b/tpls/automq_byoc_role_policy.json.tpl similarity index 100% rename from automq_byoc_role_policy.json.tpl rename to tpls/automq_byoc_role_policy.json.tpl diff --git a/tpls/userdata.tpl b/tpls/userdata.tpl new file mode 100644 index 0000000..84218b1 --- /dev/null +++ b/tpls/userdata.tpl @@ -0,0 +1,13 @@ +#cloud-config +bootcmd: + - | + if [ ! -f "/home/admin/config.properties" ]; then + touch /home/admin/config.properties + echo "cmp.provider.credential=vm-role://${aws_iam_instance_profile_arn_encoded}@aws" >> /home/admin/config.properties + echo 'cmp.provider.databucket=${automq_data_bucket}' >> /home/admin/config.properties + echo 'cmp.provider.opsBucket=${automq_ops_bucket}' >> /home/admin/config.properties + echo 'cmp.provider.instanceSecurityGroup=${instance_security_group_id}' >> /home/admin/config.properties + echo 'cmp.provider.instanceDNS=${instance_dns}' >> /home/admin/config.properties + echo 'cmp.provider.instanceProfile=${instance_profile_arn}' >> /home/admin/config.properties + echo 'cmp.environmentId=${environment_id}' >> /home/admin/config.properties + fi \ No newline at end of file From 745b2801c20f3bac925c0a8bfbb72fdbd9219471 Mon Sep 17 00:00:00 2001 From: kris20030907 <3185633428@qq.com> Date: Tue, 20 Aug 2024 11:41:07 +0800 Subject: [PATCH 2/3] refactor: Update the resource name --- aws.tf | 28 +++++++++++++--------------- main.tf | 8 ++++---- outputs.tf | 6 +++--- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/aws.tf b/aws.tf index 19feb4d..3ca62aa 100644 --- a/aws.tf +++ b/aws.tf @@ -22,18 +22,16 @@ module "automq_byoc_ops_bucket_name" { force_destroy = true } -data "aws_availability_zones" "available" {} +data "aws_availability_zones" "available_azs" {} module "automq_byoc_vpc" { source = "terraform-aws-modules/vpc/aws" version = "5.0.0" count = var.create_new_vpc ? 1 : 0 - - name = "automq-byoc-vpc-${var.automq_byoc_env_id}" cidr = "10.0.0.0/16" - azs = slice(data.aws_availability_zones.available.names, 0, 3) + azs = slice(data.aws_availability_zones.available_azs.names, 0, 3) public_subnets = ["10.0.0.0/20"] private_subnets = ["10.0.128.0/20", "10.0.144.0/20", "10.0.160.0/20"] @@ -41,16 +39,15 @@ module "automq_byoc_vpc" { enable_dns_hostnames = true tags = { - + Name = "automq-byoc-vpc-${var.automq_byoc_env_id}" automqVendor = "automq" automqEnvironmentID = var.automq_byoc_env_id } } -resource "aws_security_group" "endpoint_sg" { +resource "aws_security_group" "vpc_endpoint_sg" { count = var.create_new_vpc ? 1 : 0 - name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}" description = "Security group for VPC endpoint" vpc_id = module.automq_byoc_vpc[0].vpc_id @@ -75,13 +72,13 @@ resource "aws_security_group" "endpoint_sg" { } } -resource "aws_vpc_endpoint" "ec2" { +resource "aws_vpc_endpoint" "ec2_endpoint" { count = var.create_new_vpc ? 1 : 0 vpc_id = module.automq_byoc_vpc[0].vpc_id service_name = "com.amazonaws.${var.cloud_provider_region}.ec2" vpc_endpoint_type = "Interface" - security_group_ids = [aws_security_group.endpoint_sg[0].id] + security_group_ids = [aws_security_group.vpc_endpoint_sg[0].id] subnet_ids = module.automq_byoc_vpc[0].private_subnets private_dns_enabled = true @@ -93,7 +90,7 @@ resource "aws_vpc_endpoint" "ec2" { } } -resource "aws_vpc_endpoint" "s3" { +resource "aws_vpc_endpoint" "s3_endpoint" { count = var.create_new_vpc ? 1 : 0 vpc_id = module.automq_byoc_vpc[0].vpc_id @@ -119,7 +116,7 @@ locals { automq_ops_bucket = var.automq_byoc_ops_bucket_name == "" ? module.automq_byoc_ops_bucket_name.s3_bucket_id : "${var.automq_byoc_ops_bucket_name}-${var.automq_byoc_env_id}" } -data "aws_vpc" "selected" { +data "aws_vpc" "vpc_id" { id = local.automq_byoc_vpc_id } @@ -140,9 +137,10 @@ data "aws_ami" "marketplace_ami_details" { } } -resource "aws_security_group" "allow_all" { - vpc_id = data.aws_vpc.selected.id +resource "aws_security_group" "automq_byoc_console_sg" { + vpc_id = data.aws_vpc.vpc_id.id + name = "automq-byoc-console-sg-${var.automq_byoc_env_id}" ingress { from_port = 8080 to_port = 8080 @@ -196,7 +194,7 @@ resource "aws_iam_instance_profile" "automq_byoc_instance_profile" { role = aws_iam_role.automq_byoc_role.name } -resource "aws_route53_zone" "private" { +resource "aws_route53_zone" "private_r53" { name = "${var.automq_byoc_env_id}.automq.private" vpc { @@ -213,5 +211,5 @@ locals { } resource "aws_eip" "web_ip" { - instance = aws_instance.web.id + instance = aws_instance.automq-byoc-console.id } \ No newline at end of file diff --git a/main.tf b/main.tf index 59bfa17..32271c3 100644 --- a/main.tf +++ b/main.tf @@ -1,8 +1,8 @@ -resource "aws_instance" "web" { +resource "aws_instance" "automq-byoc-console" { ami = var.specified_ami_by_marketplace ? data.aws_ami.marketplace_ami_details.id : var.automq_byoc_env_console_ami instance_type = var.automq_byoc_ec2_instance_type subnet_id = local.automq_byoc_env_console_public_subnet_id - vpc_security_group_ids = [aws_security_group.allow_all.id] + vpc_security_group_ids = [aws_security_group.automq_byoc_console_sg.id] iam_instance_profile = aws_iam_instance_profile.automq_byoc_instance_profile.name @@ -30,8 +30,8 @@ resource "aws_instance" "web" { aws_iam_instance_profile_arn_encoded = local.aws_iam_instance_profile_arn_encoded, automq_data_bucket = local.automq_data_bucket, automq_ops_bucket = local.automq_ops_bucket, - instance_security_group_id = aws_security_group.allow_all.id, - instance_dns = aws_route53_zone.private.zone_id, + instance_security_group_id = aws_security_group.automq_byoc_console_sg.id, + instance_dns = aws_route53_zone.private_r53.zone_id, instance_profile_arn = aws_iam_instance_profile.automq_byoc_instance_profile.arn, environment_id = var.automq_byoc_env_id }) diff --git a/outputs.tf b/outputs.tf index 1c2caa8..53ac10f 100644 --- a/outputs.tf +++ b/outputs.tf @@ -15,7 +15,7 @@ output "automq_byoc_initial_username" { output "automq_byoc_initial_password" { description = "The initial password for the AutoMQ environment console. This account is used to log in to the environment, create ServiceAccounts, and manage other resources. For detailed information about environment members, please refer to the [documentation](https://docs.automq.com/automq-cloud/manage-identities-and-access/member-accounts)." - value = aws_instance.web.id + value = aws_instance.automq-byoc-console.id } output "automq_byoc_vpc_id" { @@ -25,7 +25,7 @@ output "automq_byoc_vpc_id" { output "automq_byoc_instance_id" { description = "The EC2 instance id for AutoMQ Console." - value = aws_instance.web.id + value = aws_instance.automq-byoc-console.id } /* @@ -51,7 +51,7 @@ output "automq_byoc_env_console_public_subnet_id" { output "automq_byoc_security_group_name" { description = "Security group bound to the AutoMQ BYOC service." - value = aws_security_group.allow_all.name + value = aws_security_group.automq_byoc_console_sg.name } output "automq_byoc_role_arn" { From 9012c527a36f1e60c41501c8ed1a03317b3ed8bf Mon Sep 17 00:00:00 2001 From: kris20030907 <3185633428@qq.com> Date: Tue, 20 Aug 2024 11:46:46 +0800 Subject: [PATCH 3/3] refactor: update source name --- aws.tf | 2 +- main.tf | 2 +- outputs.tf | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aws.tf b/aws.tf index 3ca62aa..360bdda 100644 --- a/aws.tf +++ b/aws.tf @@ -211,5 +211,5 @@ locals { } resource "aws_eip" "web_ip" { - instance = aws_instance.automq-byoc-console.id + instance = aws_instance.automq_byoc_console.id } \ No newline at end of file diff --git a/main.tf b/main.tf index 32271c3..1c8257a 100644 --- a/main.tf +++ b/main.tf @@ -1,4 +1,4 @@ -resource "aws_instance" "automq-byoc-console" { +resource "aws_instance" "automq_byoc_console" { ami = var.specified_ami_by_marketplace ? data.aws_ami.marketplace_ami_details.id : var.automq_byoc_env_console_ami instance_type = var.automq_byoc_ec2_instance_type subnet_id = local.automq_byoc_env_console_public_subnet_id diff --git a/outputs.tf b/outputs.tf index 53ac10f..5a37a6b 100644 --- a/outputs.tf +++ b/outputs.tf @@ -15,7 +15,7 @@ output "automq_byoc_initial_username" { output "automq_byoc_initial_password" { description = "The initial password for the AutoMQ environment console. This account is used to log in to the environment, create ServiceAccounts, and manage other resources. For detailed information about environment members, please refer to the [documentation](https://docs.automq.com/automq-cloud/manage-identities-and-access/member-accounts)." - value = aws_instance.automq-byoc-console.id + value = aws_instance.automq_byoc_console.id } output "automq_byoc_vpc_id" { @@ -25,7 +25,7 @@ output "automq_byoc_vpc_id" { output "automq_byoc_instance_id" { description = "The EC2 instance id for AutoMQ Console." - value = aws_instance.automq-byoc-console.id + value = aws_instance.automq_byoc_console.id } /* @@ -71,7 +71,7 @@ output "automq_byoc_instance_profile_arn" { output "automq_byoc_vpc_route53_zone_id" { description = "Route53 bound to the VPC." - value = aws_route53_zone.private.zone_id + value = aws_route53_zone.private_r53.zone_id } output "automq_byoc_env_console_ami" {