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
Name is only
tamarack-api
, notarn:aws:ecr:us-west-2:xxxxxxxxxxxx:repository/tamarack-api
.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. Thename
of the VPC is like a tag, theID
is something likevpc-abcdef
and the ARN would look likearn:aws:ecr:us-west-2:xxxxxxxxxxxx:
.It’s helpful to know because some resources will allow you to have duplicate
name
s but the ARN is always unique.