Skip to content

Commit

Permalink
Add subnet ARNs to outputs (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Jun 11, 2023
1 parent fde090c commit 236168c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 28 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,13 @@ Available targets:
| <a name="output_nat_ips"></a> [nat\_ips](#output\_nat\_ips) | Elastic IP Addresses in use by NAT |
| <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 |
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | IDs of the created private route tables |
| <a name="output_private_subnet_arns"></a> [private\_subnet\_arns](#output\_private\_subnet\_arns) | ARNs of the created private subnets |
| <a name="output_private_subnet_cidrs"></a> [private\_subnet\_cidrs](#output\_private\_subnet\_cidrs) | IPv4 CIDR blocks of the created private subnets |
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | IDs of the created private subnets |
| <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 |
| <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 |
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | IDs of the created public route tables |
| <a name="output_public_subnet_arns"></a> [public\_subnet\_arns](#output\_public\_subnet\_arns) | ARNs of the created public subnets |
| <a name="output_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#output\_public\_subnet\_cidrs) | IPv4 CIDR blocks of the created public subnets |
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | IDs of the created public subnets |
| <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 |
Expand Down
2 changes: 2 additions & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@
| <a name="output_nat_ips"></a> [nat\_ips](#output\_nat\_ips) | Elastic IP Addresses in use by NAT |
| <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 |
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | IDs of the created private route tables |
| <a name="output_private_subnet_arns"></a> [private\_subnet\_arns](#output\_private\_subnet\_arns) | ARNs of the created private subnets |
| <a name="output_private_subnet_cidrs"></a> [private\_subnet\_cidrs](#output\_private\_subnet\_cidrs) | IPv4 CIDR blocks of the created private subnets |
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | IDs of the created private subnets |
| <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 |
| <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 |
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | IDs of the created public route tables |
| <a name="output_public_subnet_arns"></a> [public\_subnet\_arns](#output\_public\_subnet\_arns) | ARNs of the created public subnets |
| <a name="output_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#output\_public\_subnet\_cidrs) | IPv4 CIDR blocks of the created public subnets |
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | IDs of the created public subnets |
| <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 |
Expand Down
12 changes: 11 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ output "public_subnet_ids" {
value = aws_subnet.public[*].id
}

output "public_subnet_arns" {
description = "ARNs of the created public subnets"
value = aws_subnet.public[*].arn
}

output "private_subnet_ids" {
description = "IDs of the created private subnets"
value = aws_subnet.private[*].id
}

# Provide some consistency in CDIR outputs by always returning a list.
output "private_subnet_arns" {
description = "ARNs of the created private subnets"
value = aws_subnet.private[*].arn
}

# Provide some consistency in CIDR outputs by always returning a list.
# Avoid (or at least reduce) `count` problems by toggling the return
# value via configuration rather than computing it via `compact()`.
output "public_subnet_cidrs" {
Expand Down
58 changes: 31 additions & 27 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,35 @@ variable "public_subnets_additional_tags" {
nullable = false
}

variable "subnets_per_az_count" {
type = number
description = <<-EOT
The number of subnet of each type (public or private) to provision per Availability Zone.
EOT
default = 1
nullable = false
validation {
condition = var.subnets_per_az_count > 0
# Validation error messages must be on a single line, among other restrictions.
# See https://github.com/hashicorp/terraform/issues/24123
error_message = "The `subnets_per_az` value must be greater than 0."
}
}

variable "subnets_per_az_names" {
type = list(string)

description = <<-EOT
The subnet names of each type (public or private) to provision per Availability Zone.
This variable is optional.
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`,
`named_private_route_table_ids_map` and `named_public_route_table_ids_map`
EOT
default = ["common"]
nullable = false
}

#############################################################
############## NAT instance configuration ###################
variable "nat_instance_type" {
type = string
Expand Down Expand Up @@ -515,30 +544,5 @@ variable "nat_instance_root_block_device_encrypted" {
}
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 }

variable "subnets_per_az_count" {
type = number
description = <<-EOT
The number of subnet of each type (public or private) to provision per Availability Zone.
EOT
default = 1
nullable = false
validation {
condition = var.subnets_per_az_count > 0
# Validation error messages must be on a single line, among other restrictions.
# See https://github.com/hashicorp/terraform/issues/24123
error_message = "The `subnets_per_az` value must be greater than 0."
}
}

variable "subnets_per_az_names" {
type = list(string)

description = <<-EOT
The subnet names of each type (public or private) to provision per Availability Zone.
This variable is optional.
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`,
`named_private_route_table_ids_map` and `named_public_route_table_ids_map`
EOT
default = ["common"]
nullable = false
}
############## END of NAT instance configuration ########################
############## Please add new variables above this section ##############

0 comments on commit 236168c

Please sign in to comment.