Skip to content

Commit 682e96e

Browse files
committed
Refactor outputs
1 parent 1825c40 commit 682e96e

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

modules/subnet-group/outputs.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,73 +40,73 @@ output "subnets" {
4040

4141
output "db_subnet_group_id" {
4242
description = "The ID of the RDS Subnet Group."
43-
value = element(concat(aws_db_subnet_group.this.*.id, [""]), 0)
43+
value = try(aws_db_subnet_group.this.*.id[0], null)
4444
}
4545

4646
output "db_subnet_group_arn" {
4747
description = "The ARN of the RDS Subnet Group."
48-
value = element(concat(aws_db_subnet_group.this.*.arn, [""]), 0)
48+
value = try(aws_db_subnet_group.this.*.arn[0], null)
4949
}
5050

5151
output "cache_subnet_group_id" {
5252
description = "The ID of the Elasticache Subnet Group."
53-
value = element(concat(aws_elasticache_subnet_group.this.*.id, [""]), 0)
53+
value = try(aws_elasticache_subnet_group.this.*.id[0], null)
5454
}
5555

5656
# INFO: Not support arn output
5757
# output "cache_subnet_group_arn" {
5858
# description = "The ARN of the Elasticache Subnet Group."
59-
# value = element(concat(aws_elasticache_subnet_group.this.*.arn, [""]), 0)
59+
# value = try(aws_elasticache_subnet_group.this.*.arn[0], null)
6060
# }
6161

6262
output "redshift_subnet_group_id" {
6363
description = "The ID of the Redshift Subnet Group."
64-
value = element(concat(aws_redshift_subnet_group.this.*.id, [""]), 0)
64+
value = try(aws_redshift_subnet_group.this.*.id[0], null)
6565
}
6666

6767
output "redshift_subnet_group_arn" {
6868
description = "The ARN of the Redshift Subnet Group."
69-
value = element(concat(aws_redshift_subnet_group.this.*.arn, [""]), 0)
69+
value = try(aws_redshift_subnet_group.this.*.arn[0], null)
7070
}
7171

7272
output "neptune_subnet_group_id" {
7373
description = "The ID of the Neptune DB Subnet Group."
74-
value = element(concat(aws_neptune_subnet_group.this.*.id, [""]), 0)
74+
value = try(aws_neptune_subnet_group.this.*.id[0], null)
7575
}
7676

7777
output "neptune_subnet_group_arn" {
7878
description = "The ARN of the Neptune Subnet Group."
79-
value = element(concat(aws_neptune_subnet_group.this.*.arn, [""]), 0)
79+
value = try(aws_neptune_subnet_group.this.*.arn[0], null)
8080
}
8181

8282
output "docdb_subnet_group_id" {
8383
description = "The ID of the DocumentDB Subnet Group."
84-
value = element(concat(aws_docdb_subnet_group.this.*.id, [""]), 0)
84+
value = try(aws_docdb_subnet_group.this.*.id[0], null)
8585
}
8686

8787
output "docdb_subnet_group_arn" {
8888
description = "The ARN of the DocumentDB Subnet Group."
89-
value = element(concat(aws_docdb_subnet_group.this.*.arn, [""]), 0)
89+
value = try(aws_docdb_subnet_group.this.*.arn[0], null)
9090
}
9191

9292
output "dax_subnet_group_id" {
9393
description = "The ID of the DAX Subnet Group."
94-
value = element(concat(aws_dax_subnet_group.this.*.id, [""]), 0)
94+
value = try(aws_dax_subnet_group.this.*.id[0], null)
9595
}
9696

9797
# INFO: Not support arn output
9898
# output "dax_subnet_group_arn" {
9999
# description = "The ARN of the DAX Subnet Group."
100-
# value = element(concat(aws_dax_subnet_group.this.*.arn, [""]), 0)
100+
# value = try(aws_dax_subnet_group.this.*.arn[0], null)
101101
# }
102102

103103
output "dms_replication_subnet_group_id" {
104104
description = "The ID of the DMS Replication Subnet Group."
105-
value = element(concat(aws_dms_replication_subnet_group.this.*.id, [""]), 0)
105+
value = try(aws_dms_replication_subnet_group.this.*.id[0], null)
106106
}
107107

108108
# INFO: Not support arn output
109109
# output "dms_replication_subnet_group_arn" {
110110
# description = "The ARN of the DMS Replication Subnet Group."
111-
# value = element(concat(aws_dms_replication_subnet_group.this.*.arn, [""]), 0)
111+
# value = try(aws_dms_replication_subnet_group.this.*.arn[0], null)
112112
# }

modules/vpc/outputs.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ output "dhcp_options_enabled" {
8080

8181
output "dhcp_options_id" {
8282
description = "The ID of the DHCP Options Set."
83-
value = element(concat(aws_vpc_dhcp_options.this.*.id, [""]), 0)
83+
value = try(aws_vpc_dhcp_options.this.*.id[0], null)
8484
}
8585

8686
output "dhcp_options_arn" {
8787
description = "The ARN of the DHCP Options Set."
88-
value = element(concat(aws_vpc_dhcp_options.this.*.arn, [""]), 0)
88+
value = try(aws_vpc_dhcp_options.this.*.arn[0], null)
8989
}
9090

9191
output "internet_gateway_enabled" {
@@ -95,12 +95,12 @@ output "internet_gateway_enabled" {
9595

9696
output "internet_gateway_id" {
9797
description = "The ID of the Internet Gateway."
98-
value = element(concat(aws_internet_gateway.this.*.id, [""]), 0)
98+
value = try(aws_internet_gateway.this.*.id[0], null)
9999
}
100100

101101
output "internet_gateway_arn" {
102102
description = "The ARN of the Internet Gateway."
103-
value = element(concat(aws_internet_gateway.this.*.arn, [""]), 0)
103+
value = try(aws_internet_gateway.this.*.arn[0], null)
104104
}
105105

106106
output "egress_only_internet_gateway_enabled" {
@@ -110,7 +110,7 @@ output "egress_only_internet_gateway_enabled" {
110110

111111
output "egress_only_internet_gateway_id" {
112112
description = "The ID of the Egress Only Internet Gateway."
113-
value = element(concat(aws_egress_only_internet_gateway.this.*.id, [""]), 0)
113+
value = try(aws_egress_only_internet_gateway.this.*.id[0], null)
114114
}
115115

116116
output "vpn_gateway_enabled" {
@@ -120,15 +120,15 @@ output "vpn_gateway_enabled" {
120120

121121
output "vpn_gateway_id" {
122122
description = "The ID of the Virtual Private Gateway."
123-
value = element(concat(aws_vpn_gateway.this.*.id, [""]), 0)
123+
value = try(aws_vpn_gateway.this.*.id[0], null)
124124
}
125125

126126
output "vpn_gateway_arn" {
127127
description = "The ARN of the Virtual Private Gateway."
128-
value = element(concat(aws_vpn_gateway.this.*.arn, [""]), 0)
128+
value = try(aws_vpn_gateway.this.*.arn[0], null)
129129
}
130130

131131
output "vpn_gateway_asn" {
132132
description = "The Autonomous System Number (ASN) for the Amazon side of the gateway. By default the virtual private gateway is created with the current default Amazon ASN."
133-
value = element(concat(aws_vpn_gateway.this.*.amazon_side_asn, [""]), 0)
133+
value = try(aws_vpn_gateway.this.*.amazon_side_asn[0], null)
134134
}

0 commit comments

Comments
 (0)