简体   繁体   中英

terraform import using name tag for the resource

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?

You can achieve this using filter field.

eg

data "aws_vpc" "selected" {
        filter = "tag:name=value"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM