Reputation: 123
I am trying to import the existing resources into Terraform state. But I want to automate the import along with a terraform resource creation script.
I am creating a ELB and 2 instances in existing VPC, so first I have to import the existing VPC into my state file by using the name tag of the VPC. But I am seeing the import is working only by using the id key. Is it possible to import using other parameters apart from ID?
Upvotes: 0
Views: 961
Reputation: 39
You can achieve this using filter field.
e.g.
data "aws_vpc" "selected" {
filter = "tag:name=value"
}
Upvotes: 0
Reputation: 4777
No you can't use other tags, you have to use the VPC ID to import your VPC https://www.terraform.io/docs/providers/aws/r/vpc.html https://www.terraform.io/docs/import/usage.html
Upvotes: 1