Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yannickvranckx opened this issue Jul 9, 2023 · 3 comments
Closed

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

yannickvranckx opened this issue Jul 9, 2023 · 3 comments

Comments

@yannickvranckx
Copy link

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

  • Module version [Required]: 5.0

  • Terraform version: 1.5.2 - darwin_amd64

  • Provider version(s): Installing hashicorp/aws v5.7.0...

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
Copy link

trevorrea commented Jul 13, 2023

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
Copy link

rjay98 commented Jul 30, 2023

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
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants