Terraform Import using Terraform modules in AWS

Viewed 5056

I have a Terraform template file which uses some externally sourced modules (Stored in a Git repo) and I am trying to import my ECS cluster and I have tried to run

terraform import module.module_name arn::here

But I get an error regarding resource addressing and that the resource address must contain a full resource spec.

2 Answers

Run a terraform plan first, and you will see all of the resources that your module will be attempting to create.

Find the ECS cluster referenced in there - it will likely show up as Terraform trying to create a new resource (Because that's what it should do :-))

Now that is the name of the Terraform resource you want to address, it'll be much longer than just module.module_name it'll be something like module.module_name.ecs_cluster.your_ecs_cluster_resource_name or something.

And then rather than using the ARN as the second argument, you just want to use the cluster name as the documentation states.

You're only able to import the resources within the module - the module itself has no corresponding ARN in AWS.

Related