Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform Import using Terraform modules in AWS

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.

like image 616
Luke Avatar asked Oct 30 '18 16:10

Luke


People also ask

How do I import to Terraform cloud?

To start the process of importing a resource ensure that the remote backend configuration is set up in the Terraform configuration. Run terraform init to initialize the backend. Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/aws...

What are the Terraform modules in AWS?

Currently there are 15 modules available (all include the process to work with Terraform Cloud): terraform-aws-vpc. terraform-aws-ecs-cluster. terraform-aws-ecs-fargate.


1 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.

like image 124
TJ Biddle Avatar answered Sep 26 '22 03:09

TJ Biddle