I'm using cloudformation to create a set of ECR repositories to use in my root script. For the task defintions I need to have the image names of these created repositories in a format like this:
{ACC_NR}.dkr.ecr.eu-central-1.amazonaws.com/{REPO_NAME}
When I output the created ECR in the outputs I only have 2 options. I can either get the {REPO_NAME} without the rest of the information in front of it or I will get the ARN, which contains more or less the same information but structured differently.
What is the best way to get the image name in a variable inside a CF template? Basically I need the string that you would get when nagivating to the ECR and pressing the "copy" button next to the repository.
You can construct the ARN you require "manually". For example, to add it as an output to a stack that creates AWS::ECR::Repository
, you could do the following:
Resources:
MyECRRepo:
Type: AWS::ECR::Repository
Properties:
# some properties
Outputs:
MyARN:
Value: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/{MyECRRepo}"