skip to Main Content

I’ve tried variations of the following tf file after reading these docs: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository to import an existing ECR repository.

import {
  to = aws_ecr_repository.tamarack_api
  id = "arn:aws:ecr:us-west-2:xxxxxxxxxxxx:repository/tamarack-api"
}

resource "aws_ecr_repository" tamarack_api {
  name = "tamarack-api"
}

terraform plan gives me this error:

Error: reading ECR Repository (arn:aws:ecr:us-west-2:xxxxxxxxxxxx:repository/tamarack-api): InvalidParameterException: Invalid parameter at ‘repositoryName’ failed to satisfy constraint: ‘must satisfy regular expression ‘(?:[a-z0-9]+(?:[.-][a-z0-9]+)/)[a-z0-9]+(?:[.-][a-z0-9]+)*”

I tried that regex in https://regex101.com/ using the Go language, but it matches the string tamarack-api. Thanks for any help with this!

2

Answers


  1. Name is only tamarack-api, not arn:aws:ecr:us-west-2:xxxxxxxxxxxx:repository/tamarack-api.

    Login or Signup to reply.
  2. If a resource reference includes this arn:aws:ecr:us-west-2:xxxxxxxxxxxx: part then it is actually the ARN not the name. This VPC resource is a good example. The name of the VPC is like a tag, the ID is something like vpc-abcdef and the ARN would look like arn:aws:ecr:us-west-2:xxxxxxxxxxxx:.

    It’s helpful to know because some resources will allow you to have duplicate names but the ARN is always unique.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search