0

I am trying to import some of my ecr repositories into terraform. However, when I plan them, it seems like terraform wants to create them.

I followed this method: previously wrote the configuration (ecr.tf). Did terraform import aws_ecr_repository.ecr-blabla blabla. Then terraform plan -out=plan.txt.

Terraform version: v0.10.8

ecr.tf:

resource "aws_ecr_repository" "ecr-blabla" {
  name = "blabla"
}

terraform plan -out=plan.txt

 aws_ecr_repository.ecr-blabla
      id:                   <computed>
      arn:                  <computed>
      image_tag_mutability: "MUTABLE"
      name:                 "blabla"
      registry_id:          <computed>
      repository_url:       <computed>

Result of the import:

terraform import aws_ecr_repository.ecr-blabla blabla
aws_ecr_repository.ecr-blabla: Importing from ID "blabla"...
aws_ecr_repository.ecr-blabla: Import complete!
  Imported aws_ecr_repository (ID: blabla)
aws_ecr_repository.ecr-blabla: Refreshing state... (ID: blabla)

Import successful!

I would like to basically leave those resources alone (except if I want to destroy them, but that's not the question here). I didn't do anything particlular for those repositories. They are in use and and I would like to not have to delete them and/or delete them.

shrimpy
  • 653
  • 3
  • 11
  • 27
  • 1
    What is the output of the `import` command? What in the plan output indicates Terraform would create a new resource? – Matthew Schuchard Sep 24 '19 at 15:55
  • @MattSchuchard I added the output of the import command. Something weird happened: I deleted the tfstate (pardon me, I was growing annoyed) and just redid all the import... And now it's all right! I'm not sure what happened – shrimpy Sep 25 '19 at 13:24
  • Well glad the situation resolved for you. You may want to also look into the `terraform state` command since that may have been relevant here. – Matthew Schuchard Sep 25 '19 at 13:25
  • I did `terraform state` yesterday, and I could see all the resources I imported there. When running the plan, it still wanted to create them... I have an "old" version of terraform, maybe updating it will avoid little hiccups like that? – shrimpy Sep 25 '19 at 14:03

0 Answers0