terraform-aws-modules / terraform-aws-vpc

Terraform module to create AWS VPC resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws
Apache License 2.0
2.98k stars 4.44k forks source link

Can you extract the subnet-ids from the VPC module? #961

Closed yannickvranckx closed 1 year ago

yannickvranckx commented 1 year ago

Description

Is there a possibility to extract the subnet-ids from the module when it is being deployed? For example: To create a Transit Gateway attachment to an existing Transit Gateway for example, as that resource needs subnet-ids to operate.

Versions

Reproduction Code [Required]

` module "vpc" { source = "terraform-aws-modules/vpc/aws" #Source of the module

name = var.name cidr = var.cidr

azs = var.azs private_subnets = var.private_subnets public_subnets = var.public_subnets

enable_nat_gateway = false #Disable the NAT GW single_nat_gateway = false #NAT not HA enable_vpn_gateway = false enable_flow_log = true #Enable flow logs flow_log_destination_type = "s3" # Set the destination flow_log_destination_arn = resource.aws_s3_bucket.flow_logs.arn enable_dns_hostnames = true enable_dns_support = true } `

trevorrea commented 1 year ago

The module has outputs for this purpose. See https://github.com/terraform-aws-modules/terraform-aws-vpc#output_private_subnets and https://github.com/terraform-aws-modules/terraform-aws-vpc#output_private_subnets etc. etc.

All the outputs are documented in the README file.

rjay98 commented 1 year ago

I'm using cdktf and I'm getting an error - instead of the subnetIds (e.g., subnet-00XXXX) the outputs are the IPv4 CIDRs (e.g., 10.0.1.0/24)

Screenshot 2023-07-29 at 6 45 23 PM Screenshot 2023-07-29 at 6 46 16 PM

Edit: I'm working around this by creating a new data_aws_subnets/DataAwsSubnets resource to look up by vpc-id and my tags, but just an FYI!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.