Skip to content

Commit 236168c

Browse files
authored
Add subnet ARNs to outputs (#188)
1 parent fde090c commit 236168c

File tree

4 files changed

+46
-28
lines changed

4 files changed

+46
-28
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,13 @@ Available targets:
432432
| <a name="output_nat_ips"></a> [nat\_ips](#output\_nat\_ips) | Elastic IP Addresses in use by NAT |
433433
| <a name="output_private_network_acl_id"></a> [private\_network\_acl\_id](#output\_private\_network\_acl\_id) | ID of the Network ACL created for private subnets |
434434
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | IDs of the created private route tables |
435+
| <a name="output_private_subnet_arns"></a> [private\_subnet\_arns](#output\_private\_subnet\_arns) | ARNs of the created private subnets |
435436
| <a name="output_private_subnet_cidrs"></a> [private\_subnet\_cidrs](#output\_private\_subnet\_cidrs) | IPv4 CIDR blocks of the created private subnets |
436437
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | IDs of the created private subnets |
437438
| <a name="output_private_subnet_ipv6_cidrs"></a> [private\_subnet\_ipv6\_cidrs](#output\_private\_subnet\_ipv6\_cidrs) | IPv6 CIDR blocks of the created private subnets |
438439
| <a name="output_public_network_acl_id"></a> [public\_network\_acl\_id](#output\_public\_network\_acl\_id) | ID of the Network ACL created for public subnets |
439440
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | IDs of the created public route tables |
441+
| <a name="output_public_subnet_arns"></a> [public\_subnet\_arns](#output\_public\_subnet\_arns) | ARNs of the created public subnets |
440442
| <a name="output_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#output\_public\_subnet\_cidrs) | IPv4 CIDR blocks of the created public subnets |
441443
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | IDs of the created public subnets |
442444
| <a name="output_public_subnet_ipv6_cidrs"></a> [public\_subnet\_ipv6\_cidrs](#output\_public\_subnet\_ipv6\_cidrs) | IPv6 CIDR blocks of the created public subnets |

docs/terraform.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@
169169
| <a name="output_nat_ips"></a> [nat\_ips](#output\_nat\_ips) | Elastic IP Addresses in use by NAT |
170170
| <a name="output_private_network_acl_id"></a> [private\_network\_acl\_id](#output\_private\_network\_acl\_id) | ID of the Network ACL created for private subnets |
171171
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | IDs of the created private route tables |
172+
| <a name="output_private_subnet_arns"></a> [private\_subnet\_arns](#output\_private\_subnet\_arns) | ARNs of the created private subnets |
172173
| <a name="output_private_subnet_cidrs"></a> [private\_subnet\_cidrs](#output\_private\_subnet\_cidrs) | IPv4 CIDR blocks of the created private subnets |
173174
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | IDs of the created private subnets |
174175
| <a name="output_private_subnet_ipv6_cidrs"></a> [private\_subnet\_ipv6\_cidrs](#output\_private\_subnet\_ipv6\_cidrs) | IPv6 CIDR blocks of the created private subnets |
175176
| <a name="output_public_network_acl_id"></a> [public\_network\_acl\_id](#output\_public\_network\_acl\_id) | ID of the Network ACL created for public subnets |
176177
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | IDs of the created public route tables |
178+
| <a name="output_public_subnet_arns"></a> [public\_subnet\_arns](#output\_public\_subnet\_arns) | ARNs of the created public subnets |
177179
| <a name="output_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#output\_public\_subnet\_cidrs) | IPv4 CIDR blocks of the created public subnets |
178180
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | IDs of the created public subnets |
179181
| <a name="output_public_subnet_ipv6_cidrs"></a> [public\_subnet\_ipv6\_cidrs](#output\_public\_subnet\_ipv6\_cidrs) | IPv6 CIDR blocks of the created public subnets |

outputs.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ output "public_subnet_ids" {
1515
value = aws_subnet.public[*].id
1616
}
1717

18+
output "public_subnet_arns" {
19+
description = "ARNs of the created public subnets"
20+
value = aws_subnet.public[*].arn
21+
}
22+
1823
output "private_subnet_ids" {
1924
description = "IDs of the created private subnets"
2025
value = aws_subnet.private[*].id
2126
}
2227

23-
# Provide some consistency in CDIR outputs by always returning a list.
28+
output "private_subnet_arns" {
29+
description = "ARNs of the created private subnets"
30+
value = aws_subnet.private[*].arn
31+
}
32+
33+
# Provide some consistency in CIDR outputs by always returning a list.
2434
# Avoid (or at least reduce) `count` problems by toggling the return
2535
# value via configuration rather than computing it via `compact()`.
2636
output "public_subnet_cidrs" {

variables.tf

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,35 @@ variable "public_subnets_additional_tags" {
446446
nullable = false
447447
}
448448

449+
variable "subnets_per_az_count" {
450+
type = number
451+
description = <<-EOT
452+
The number of subnet of each type (public or private) to provision per Availability Zone.
453+
EOT
454+
default = 1
455+
nullable = false
456+
validation {
457+
condition = var.subnets_per_az_count > 0
458+
# Validation error messages must be on a single line, among other restrictions.
459+
# See https://github.com/hashicorp/terraform/issues/24123
460+
error_message = "The `subnets_per_az` value must be greater than 0."
461+
}
462+
}
463+
464+
variable "subnets_per_az_names" {
465+
type = list(string)
466+
467+
description = <<-EOT
468+
The subnet names of each type (public or private) to provision per Availability Zone.
469+
This variable is optional.
470+
If a list of names is provided, the list items will be used as keys in the outputs `named_private_subnets_map`, `named_public_subnets_map`,
471+
`named_private_route_table_ids_map` and `named_public_route_table_ids_map`
472+
EOT
473+
default = ["common"]
474+
nullable = false
475+
}
476+
477+
#############################################################
449478
############## NAT instance configuration ###################
450479
variable "nat_instance_type" {
451480
type = string
@@ -515,30 +544,5 @@ variable "nat_instance_root_block_device_encrypted" {
515544
}
516545
locals { nat_instance_root_block_device_encrypted = var.root_block_device_encrypted == null ? var.nat_instance_root_block_device_encrypted : var.root_block_device_encrypted }
517546

518-
variable "subnets_per_az_count" {
519-
type = number
520-
description = <<-EOT
521-
The number of subnet of each type (public or private) to provision per Availability Zone.
522-
EOT
523-
default = 1
524-
nullable = false
525-
validation {
526-
condition = var.subnets_per_az_count > 0
527-
# Validation error messages must be on a single line, among other restrictions.
528-
# See https://github.com/hashicorp/terraform/issues/24123
529-
error_message = "The `subnets_per_az` value must be greater than 0."
530-
}
531-
}
532-
533-
variable "subnets_per_az_names" {
534-
type = list(string)
535-
536-
description = <<-EOT
537-
The subnet names of each type (public or private) to provision per Availability Zone.
538-
This variable is optional.
539-
If a list of names is provided, the list items will be used as keys in the outputs `named_private_subnets_map`, `named_public_subnets_map`,
540-
`named_private_route_table_ids_map` and `named_public_route_table_ids_map`
541-
EOT
542-
default = ["common"]
543-
nullable = false
544-
}
547+
############## END of NAT instance configuration ########################
548+
############## Please add new variables above this section ##############

0 commit comments

Comments
 (0)