Reputation: 325
Currently I have a aws infrastructure that is created manually. I want to import configuration of vpc and subnets. With the
terraform import aws_vpc.example vpc-id
I can get the cidr block of the vpc. Further with the cidr block I also want to get all the subnet ids as well. Is there a way to get all subnet ids with import command or I have to manually enter every id?
I cannot find any document where all subnet values can be imported? If there is please share
Thank you in advance!
Upvotes: 0
Views: 4209
Reputation: 238299
If you already have vpc_id, then you can use aws_subnet_ids data to automatically get the ids of its subsets.
Example from docs:
data "aws_subnet_ids" "example" {
vpc_id = aws_vpc.example.vpc_id
}
Upvotes: 2