From 5a4570be725dbbbc57f92ecfb707bfb39a8c0812 Mon Sep 17 00:00:00 2001 From: xpk Date: Tue, 22 Oct 2024 17:09:26 +0800 Subject: [PATCH] UPD: Improved outputs with more details. --- modules/networking/VpcSubnet/README.md | 22 ++++++++--------- modules/networking/VpcSubnet/outputs.tf | 33 +++++++++++++++++++------ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/modules/networking/VpcSubnet/README.md b/modules/networking/VpcSubnet/README.md index 91a45d2..aa30728 100644 --- a/modules/networking/VpcSubnet/README.md +++ b/modules/networking/VpcSubnet/README.md @@ -1,5 +1,4 @@ -# Overview This module performs the following tasks: - Create VPC, vpcflow log @@ -78,17 +77,16 @@ This module performs the following tasks: | Name | Description | |------|-------------| -| azs | n/a | -| private-subnet-azs | n/a | -| private-subnet-ids | n/a | -| private\_subnets | n/a | -| public-route-table-id | n/a | -| public-subnet-azs | n/a | -| public-subnet-ids | n/a | -| public\_subnets | n/a | -| secondary\_cidr\_blocks | n/a | -| vpc-cidr | n/a | -| vpc\_id | n/a | +| private-subnet-details | Details of private subnets | +| private-subnet-ids | List of private subnet id | +| private\_subnets | Private subnet cidrs | +| public-route-table-id | Public route table id | +| public-subnet-details | Details of public subnets | +| public-subnet-ids | List of public subnet id | +| public\_subnets | Public subnet cidrs | +| secondary\_cidr\_blocks | Secondary CIDR block | +| vpc-cidr | VPC primary cidr | +| vpc\_id | VPC id | --- ## Authorship diff --git a/modules/networking/VpcSubnet/outputs.tf b/modules/networking/VpcSubnet/outputs.tf index 4b54b12..b04b319 100644 --- a/modules/networking/VpcSubnet/outputs.tf +++ b/modules/networking/VpcSubnet/outputs.tf @@ -1,24 +1,30 @@ output "vpc_id" { + description = "VPC id" value = aws_vpc.vpc.id } output "vpc-cidr" { + description = "VPC primary cidr" value = aws_vpc.vpc.cidr_block } output "public_subnets" { + description = "Public subnet cidrs" value = aws_subnet.public-subnets.*.cidr_block } output "private_subnets" { + description = "Private subnet cidrs" value = aws_subnet.private-subnets.*.cidr_block } output "public-subnet-ids" { + description = "List of public subnet id" value = aws_subnet.public-subnets.*.id } output "private-subnet-ids" { + description = "List of private subnet id" value = aws_subnet.private-subnets.*.id } @@ -27,6 +33,7 @@ output "private-subnet-ids" { # } output "public-route-table-id" { + description = "Public route table id" value = aws_route_table.public-route-table.*.id } @@ -35,17 +42,29 @@ output "public-route-table-id" { # } output "secondary_cidr_blocks" { + description = "Secondary CIDR block" value = var.secondary_cidr_blocks } -output "public-subnet-azs" { - value = distinct(aws_subnet.public-subnets.*.availability_zone) +output "public-subnet-details" { + description = "Details of public subnets" + value = [ + for k, v in aws_subnet.public-subnets : { + cidr = v.cidr_block, + az = v.availability_zone, + name = v.tags["Name"] + } + ] } -output "private-subnet-azs" { - value = distinct(aws_subnet.private-subnets.*.availability_zone) +output "private-subnet-details" { + description = "Details of private subnets" + value = [ + for k, v in aws_subnet.public-subnets : { + cidr = v.cidr_block, + az = v.availability_zone, + name = v.tags["Name"] + } + ] } -output "azs" { - value = data.aws_availability_zones.available-az.names -} \ No newline at end of file