Yet another one DevOps blog

Ops and DevOps stories

Aug 8, 2019 - 1 minute read - Comments - technical terraform devops

Terraform >= 0.12.6 map resources import


In terraform 0.12.6 developers added a nice feature - Multiple Resource Instances Defined By a Map

So now we can create multiple resources and then safely delete one in the middle of map (that was a bit of a pain with lists).

But how to import new map resources?

I’ll show on example of import with hypotetical DNS module for AWS Route53 record:

terraform import module.my_domain_com_dns.aws_route53_record.soa[\"@\"] DOMAINZONEID_mydomain.com_SOA

The most non-obvious part is escaping, so if you map key is @ you will need to escape it: \"@\"