Skip to content

Commit

Permalink
feat: making the outputs consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
gambol99 committed Apr 13, 2024
1 parent c1a5c8f commit 7b8c49a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 60 deletions.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,25 @@ The `terraform-docs` utility is used to generate this README. Follow the below s

| Name | Description |
|------|-------------|
| <a name="output_nat_public_ips"></a> [nat\_public\_ips](#output\_nat\_public\_ips) | The public IPs of the NAT Gateways |
| <a name="output_natgw_id_per_az"></a> [natgw\_id\_per\_az](#output\_natgw\_id\_per\_az) | The IDs of the NAT Gateways |
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | The IDs of the private route tables |
| <a name="output_private_subnet_attributes_by_az"></a> [private\_subnet\_attributes\_by\_az](#output\_private\_subnet\_attributes\_by\_az) | The attributes of the private subnets |
| <a name="output_nat_public_ips"></a> [nat\_public\_ips](#output\_nat\_public\_ips) | The public IPs of the NAT Gateways i.e [public\_ip, public\_ip] |
| <a name="output_natgw_id_per_az"></a> [natgw\_id\_per\_az](#output\_natgw\_id\_per\_az) | The IDs of the NAT Gateways (see aws-ia/vpc/aws for details) |
| <a name="output_private_route_table_ids"></a> [private\_route\_table\_ids](#output\_private\_route\_table\_ids) | The IDs of the private route tables ie. [route\_table\_id, route\_table\_id] |
| <a name="output_private_subnet_attributes_by_az"></a> [private\_subnet\_attributes\_by\_az](#output\_private\_subnet\_attributes\_by\_az) | The attributes of the private subnets (see aws-ia/vpc/aws for details) |
| <a name="output_private_subnet_cidr_by_id"></a> [private\_subnet\_cidr\_by\_id](#output\_private\_subnet\_cidr\_by\_id) | A map of the private subnet ID to CIDR block i.e. us-west-2a => subnet\_cidr |
| <a name="output_private_subnet_cidrs"></a> [private\_subnet\_cidrs](#output\_private\_subnet\_cidrs) | A list of the CIDRs for the private subnets |
| <a name="output_private_subnet_id_by_az"></a> [private\_subnet\_id\_by\_az](#output\_private\_subnet\_id\_by\_az) | A map of availability zone to subnet id of the private subnets i.e. eu-west-2a => subnet\_id |
| <a name="output_private_subnet_id_to_cidr"></a> [private\_subnet\_id\_to\_cidr](#output\_private\_subnet\_id\_to\_cidr) | A map of the private subnet ID to CIDR block |
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | The IDs of the private subnets |
| <a name="output_private_subnet_list"></a> [private\_subnet\_list](#output\_private\_subnet\_list) | A list of the CIDRs for the private subnets |
| <a name="output_private_subnet_netmask"></a> [private\_subnet\_netmask](#output\_private\_subnet\_netmask) | The netmask for the private subnets |
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | The IDs of the public route tables |
| <a name="output_public_subnet_attributes_by_az"></a> [public\_subnet\_attributes\_by\_az](#output\_public\_subnet\_attributes\_by\_az) | The attributes of the public subnets |
| <a name="output_private_subnet_ids"></a> [private\_subnet\_ids](#output\_private\_subnet\_ids) | The IDs of the private subnets i.e. [subnet\_id, subnet\_id] |
| <a name="output_public_route_table_ids"></a> [public\_route\_table\_ids](#output\_public\_route\_table\_ids) | The IDs of the public route tables ie. [route\_table\_id, route\_table\_id] |
| <a name="output_public_subnet_attributes_by_az"></a> [public\_subnet\_attributes\_by\_az](#output\_public\_subnet\_attributes\_by\_az) | The attributes of the public subnets (see aws-ia/vpc/aws for details) |
| <a name="output_public_subnet_cidr_by_id"></a> [public\_subnet\_cidr\_by\_id](#output\_public\_subnet\_cidr\_by\_id) | A map of the public subnet ID to CIDR block i.e. us-west-2a => subnet\_cidr |
| <a name="output_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#output\_public\_subnet\_cidrs) | A list of the CIDRs for the public subnets i.e. [subnet\_cidr, subnet\_cidr] |
| <a name="output_public_subnet_id_by_az"></a> [public\_subnet\_id\_by\_az](#output\_public\_subnet\_id\_by\_az) | A map of availability zone to subnet id of the public subnets i.e. eu-west-2a => subnet\_id |
| <a name="output_public_subnet_id_to_cidr"></a> [public\_subnet\_id\_to\_cidr](#output\_public\_subnet\_id\_to\_cidr) | A map of the public subnet ID to CIDR block |
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | The IDs of the public subnets |
| <a name="output_public_subnet_list"></a> [public\_subnet\_list](#output\_public\_subnet\_list) | A list of the CIDRs for the public subnets |
| <a name="output_public_subnet_netmask"></a> [public\_subnet\_netmask](#output\_public\_subnet\_netmask) | The netmask for the public subnets |
| <a name="output_rt_attributes_by_type_by_az"></a> [rt\_attributes\_by\_type\_by\_az](#output\_rt\_attributes\_by\_type\_by\_az) | The attributes of the route tables |
| <a name="output_transit_gateway_attachment_id"></a> [transit\_gateway\_attachment\_id](#output\_transit\_gateway\_attachment\_id) | The ID of the transit gateway attachment |
| <a name="output_transit_route_table_by_az"></a> [transit\_route\_table\_by\_az](#output\_transit\_route\_table\_by\_az) | A map of availability zone to transit gateway route table ID |
| <a name="output_transit_subnet_attributes_by_az"></a> [transit\_subnet\_attributes\_by\_az](#output\_transit\_subnet\_attributes\_by\_az) | The attributes of the transit gateway subnets |
| <a name="output_transit_subnet_ids"></a> [transit\_subnet\_ids](#output\_transit\_subnet\_ids) | The IDs of the transit gateway subnets |
| <a name="output_public_subnet_ids"></a> [public\_subnet\_ids](#output\_public\_subnet\_ids) | The IDs of the public subnets i.e. [subnet\_id, subnet\_id] |
| <a name="output_rt_attributes_by_type_by_az"></a> [rt\_attributes\_by\_type\_by\_az](#output\_rt\_attributes\_by\_type\_by\_az) | The attributes of the route tables (see aws-ia/vpc/aws for details) |
| <a name="output_transit_gateway_attachment_id"></a> [transit\_gateway\_attachment\_id](#output\_transit\_gateway\_attachment\_id) | The ID of the transit gateway attachment if enabled |
| <a name="output_transit_route_table_by_az"></a> [transit\_route\_table\_by\_az](#output\_transit\_route\_table\_by\_az) | A map of availability zone to transit gateway route table ID i.e eu-west-2a => route\_table\_id |
| <a name="output_transit_route_table_ids"></a> [transit\_route\_table\_ids](#output\_transit\_route\_table\_ids) | The IDs of the transit gateway route tables ie. [route\_table\_id, route\_table\_id] |
| <a name="output_transit_subnet_attributes_by_az"></a> [transit\_subnet\_attributes\_by\_az](#output\_transit\_subnet\_attributes\_by\_az) | The attributes of the transit gateway subnets (see aws-ia/vpc/aws for details) |
| <a name="output_transit_subnet_ids"></a> [transit\_subnet\_ids](#output\_transit\_subnet\_ids) | The IDs of the transit gateway subnets ie. [subnet\_id, subnet\_id] |
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC |
<!-- END_TF_DOCS -->
2 changes: 2 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ locals {
public_subnet_ids = [for k, x in module.vpc.public_subnet_attributes_by_az : x.id]
# The subnet id for the transit subnets
transit_subnet_ids = [for k, x in module.vpc.tgw_subnet_attributes_by_az : x.id]
# A list of transit route table ids
transit_route_table_ids = var.enable_transit_gateway ? [for k, x in module.vpc.rt_attributes_by_type_by_az.transit_gateway : x.id] : []
# The routing tables for the private subnets
private_route_table_ids = [for k, x in module.vpc.rt_attributes_by_type_by_az.private : x.id]
# The transgit gateway route table ids
Expand Down
73 changes: 32 additions & 41 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
#
## Related to the outputs of the module
#

output "vpc_id" {
description = "The ID of the VPC"
value = module.vpc.vpc_attributes.id
}

output "private_subnet_netmask" {
description = "The netmask for the private subnets"
value = var.private_subnet_netmask
}

output "public_subnet_netmask" {
description = "The netmask for the public subnets"
value = var.public_subnet_netmask
}

output "private_subnet_list" {
output "private_subnet_cidrs" {
description = "A list of the CIDRs for the private subnets"
value = local.private_subnet_cidrs
}

output "private_subnet_id_to_cidr" {
description = "A map of the private subnet ID to CIDR block"
value = local.private_subnet_cidr_by_id
output "public_subnet_cidrs" {
description = "A list of the CIDRs for the public subnets i.e. [subnet_cidr, subnet_cidr]"
value = local.public_subnet_cidrs
}

output "public_subnet_id_to_cidr" {
description = "A map of the public subnet ID to CIDR block"
value = local.public_subnet_cidr_by_id
output "private_subnet_cidr_by_id" {
description = "A map of the private subnet ID to CIDR block i.e. us-west-2a => subnet_cidr"
value = local.private_subnet_cidr_by_id
}

output "public_subnet_list" {
description = "A list of the CIDRs for the public subnets"
value = local.public_subnet_cidrs
output "public_subnet_cidr_by_id" {
description = "A map of the public subnet ID to CIDR block i.e. us-west-2a => subnet_cidr"
value = local.public_subnet_cidr_by_id
}

output "private_subnet_id_by_az" {
Expand All @@ -48,67 +35,71 @@ output "public_subnet_id_by_az" {
}

output "private_subnet_attributes_by_az" {
description = "The attributes of the private subnets"
description = "The attributes of the private subnets (see aws-ia/vpc/aws for details)"
value = module.vpc.private_subnet_attributes_by_az
}

output "public_subnet_attributes_by_az" {
description = "The attributes of the public subnets"
description = "The attributes of the public subnets (see aws-ia/vpc/aws for details)"
value = var.public_subnet_netmask > 0 ? module.vpc.public_subnet_attributes_by_az : null
}

output "transit_subnet_attributes_by_az" {
description = "The attributes of the transit gateway subnets"
description = "The attributes of the transit gateway subnets (see aws-ia/vpc/aws for details)"
value = var.enable_transit_gateway ? module.vpc.tgw_subnet_attributes_by_az : null
}

output "natgw_id_per_az" {
description = "The IDs of the NAT Gateways"
description = "The IDs of the NAT Gateways (see aws-ia/vpc/aws for details)"
value = var.enable_nat_gateway ? module.vpc.natgw_id_per_az : null
}

output "rt_attributes_by_type_by_az" {
description = "The attributes of the route tables"
description = "The attributes of the route tables (see aws-ia/vpc/aws for details)"
value = module.vpc.rt_attributes_by_type_by_az
}

output "private_subnet_ids" {
description = "The IDs of the private subnets"
description = "The IDs of the private subnets i.e. [subnet_id, subnet_id]"
value = local.private_subnet_ids
}

output "public_subnet_ids" {
description = "The IDs of the public subnets"
description = "The IDs of the public subnets i.e. [subnet_id, subnet_id]"
value = local.public_subnet_ids
}

output "transit_subnet_ids" {
description = "The IDs of the transit gateway subnets ie. [subnet_id, subnet_id]"
value = var.enable_transit_gateway ? local.transit_subnet_ids : null
}

output "private_route_table_ids" {
description = "The IDs of the private route tables"
description = "The IDs of the private route tables ie. [route_table_id, route_table_id]"
value = local.private_route_table_ids
}

output "public_route_table_ids" {
description = "The IDs of the public route tables"
description = "The IDs of the public route tables ie. [route_table_id, route_table_id]"
value = local.public_route_table_ids
}

output "transit_route_table_ids" {
description = "The IDs of the transit gateway route tables ie. [route_table_id, route_table_id]"
value = var.enable_transit_gateway ? local.transit_route_table_ids : null
}

output "transit_route_table_by_az" {
description = "A map of availability zone to transit gateway route table ID"
description = "A map of availability zone to transit gateway route table ID i.e eu-west-2a => route_table_id"
value = var.enable_transit_gateway ? local.transit_route_table_by_az : null
}

output "transit_gateway_attachment_id" {
description = "The ID of the transit gateway attachment"
description = "The ID of the transit gateway attachment if enabled"
value = var.enable_transit_gateway ? module.vpc.transit_gateway_attachment_id : null
}

output "transit_subnet_ids" {
description = "The IDs of the transit gateway subnets"
value = var.enable_transit_gateway ? local.transit_subnet_ids : null
}

output "nat_public_ips" {
description = "The public IPs of the NAT Gateways"
description = "The public IPs of the NAT Gateways i.e [public_ip, public_ip]"
value = var.enable_nat_gateway ? [] : [for x in module.vpc.nat_gateway_attributes_by_az : x.public_ip]
}

0 comments on commit 7b8c49a

Please sign in to comment.