Skip to content

Commit 745b280

Browse files
committed
refactor: Update the resource name
1 parent 0b0c8de commit 745b280

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

aws.tf

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,32 @@ module "automq_byoc_ops_bucket_name" {
2222
force_destroy = true
2323
}
2424

25-
data "aws_availability_zones" "available" {}
25+
data "aws_availability_zones" "available_azs" {}
2626

2727
module "automq_byoc_vpc" {
2828
source = "terraform-aws-modules/vpc/aws"
2929
version = "5.0.0"
3030

3131
count = var.create_new_vpc ? 1 : 0
32-
33-
name = "automq-byoc-vpc-${var.automq_byoc_env_id}"
3432
cidr = "10.0.0.0/16"
3533

36-
azs = slice(data.aws_availability_zones.available.names, 0, 3)
34+
azs = slice(data.aws_availability_zones.available_azs.names, 0, 3)
3735
public_subnets = ["10.0.0.0/20"]
3836
private_subnets = ["10.0.128.0/20", "10.0.144.0/20", "10.0.160.0/20"]
3937

4038
enable_dns_support = true
4139
enable_dns_hostnames = true
4240

4341
tags = {
44-
42+
Name = "automq-byoc-vpc-${var.automq_byoc_env_id}"
4543
automqVendor = "automq"
4644
automqEnvironmentID = var.automq_byoc_env_id
4745
}
4846
}
4947

50-
resource "aws_security_group" "endpoint_sg" {
48+
resource "aws_security_group" "vpc_endpoint_sg" {
5149
count = var.create_new_vpc ? 1 : 0
5250

53-
name = "automq-byoc-endpoint-sg-${var.automq_byoc_env_id}"
5451
description = "Security group for VPC endpoint"
5552
vpc_id = module.automq_byoc_vpc[0].vpc_id
5653

@@ -75,13 +72,13 @@ resource "aws_security_group" "endpoint_sg" {
7572
}
7673
}
7774

78-
resource "aws_vpc_endpoint" "ec2" {
75+
resource "aws_vpc_endpoint" "ec2_endpoint" {
7976
count = var.create_new_vpc ? 1 : 0
8077

8178
vpc_id = module.automq_byoc_vpc[0].vpc_id
8279
service_name = "com.amazonaws.${var.cloud_provider_region}.ec2"
8380
vpc_endpoint_type = "Interface"
84-
security_group_ids = [aws_security_group.endpoint_sg[0].id]
81+
security_group_ids = [aws_security_group.vpc_endpoint_sg[0].id]
8582
subnet_ids = module.automq_byoc_vpc[0].private_subnets
8683

8784
private_dns_enabled = true
@@ -93,7 +90,7 @@ resource "aws_vpc_endpoint" "ec2" {
9390
}
9491
}
9592

96-
resource "aws_vpc_endpoint" "s3" {
93+
resource "aws_vpc_endpoint" "s3_endpoint" {
9794
count = var.create_new_vpc ? 1 : 0
9895

9996
vpc_id = module.automq_byoc_vpc[0].vpc_id
@@ -119,7 +116,7 @@ locals {
119116
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}"
120117
}
121118

122-
data "aws_vpc" "selected" {
119+
data "aws_vpc" "vpc_id" {
123120
id = local.automq_byoc_vpc_id
124121
}
125122

@@ -140,9 +137,10 @@ data "aws_ami" "marketplace_ami_details" {
140137
}
141138
}
142139

143-
resource "aws_security_group" "allow_all" {
144-
vpc_id = data.aws_vpc.selected.id
140+
resource "aws_security_group" "automq_byoc_console_sg" {
141+
vpc_id = data.aws_vpc.vpc_id.id
145142

143+
name = "automq-byoc-console-sg-${var.automq_byoc_env_id}"
146144
ingress {
147145
from_port = 8080
148146
to_port = 8080
@@ -196,7 +194,7 @@ resource "aws_iam_instance_profile" "automq_byoc_instance_profile" {
196194
role = aws_iam_role.automq_byoc_role.name
197195
}
198196

199-
resource "aws_route53_zone" "private" {
197+
resource "aws_route53_zone" "private_r53" {
200198
name = "${var.automq_byoc_env_id}.automq.private"
201199

202200
vpc {
@@ -213,5 +211,5 @@ locals {
213211
}
214212

215213
resource "aws_eip" "web_ip" {
216-
instance = aws_instance.web.id
214+
instance = aws_instance.automq-byoc-console.id
217215
}

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
resource "aws_instance" "web" {
1+
resource "aws_instance" "automq-byoc-console" {
22
ami = var.specified_ami_by_marketplace ? data.aws_ami.marketplace_ami_details.id : var.automq_byoc_env_console_ami
33
instance_type = var.automq_byoc_ec2_instance_type
44
subnet_id = local.automq_byoc_env_console_public_subnet_id
5-
vpc_security_group_ids = [aws_security_group.allow_all.id]
5+
vpc_security_group_ids = [aws_security_group.automq_byoc_console_sg.id]
66

77
iam_instance_profile = aws_iam_instance_profile.automq_byoc_instance_profile.name
88

@@ -30,8 +30,8 @@ resource "aws_instance" "web" {
3030
aws_iam_instance_profile_arn_encoded = local.aws_iam_instance_profile_arn_encoded,
3131
automq_data_bucket = local.automq_data_bucket,
3232
automq_ops_bucket = local.automq_ops_bucket,
33-
instance_security_group_id = aws_security_group.allow_all.id,
34-
instance_dns = aws_route53_zone.private.zone_id,
33+
instance_security_group_id = aws_security_group.automq_byoc_console_sg.id,
34+
instance_dns = aws_route53_zone.private_r53.zone_id,
3535
instance_profile_arn = aws_iam_instance_profile.automq_byoc_instance_profile.arn,
3636
environment_id = var.automq_byoc_env_id
3737
})

outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ output "automq_byoc_initial_username" {
1515

1616
output "automq_byoc_initial_password" {
1717
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)."
18-
value = aws_instance.web.id
18+
value = aws_instance.automq-byoc-console.id
1919
}
2020

2121
output "automq_byoc_vpc_id" {
@@ -25,7 +25,7 @@ output "automq_byoc_vpc_id" {
2525

2626
output "automq_byoc_instance_id" {
2727
description = "The EC2 instance id for AutoMQ Console."
28-
value = aws_instance.web.id
28+
value = aws_instance.automq-byoc-console.id
2929
}
3030

3131
/*
@@ -51,7 +51,7 @@ output "automq_byoc_env_console_public_subnet_id" {
5151
5252
output "automq_byoc_security_group_name" {
5353
description = "Security group bound to the AutoMQ BYOC service."
54-
value = aws_security_group.allow_all.name
54+
value = aws_security_group.automq_byoc_console_sg.name
5555
}
5656
5757
output "automq_byoc_role_arn" {

0 commit comments

Comments
 (0)