vickey99
vickey99

Reputation: 187

Jenkins pipeline on EC2 to push images in ECR

I have EC2 in my Dev environment and i am building CICD in this EC2 and pushing images to ECR.

I am using below commands in my Jenkinsfile to push image to ECR.

 sh '$(aws ecr get-login --no-include-email --region us-east-1)'
 sh 'docker push 572205960066.dkr.ecr.us-east-1.amazonaws.com/mh367/dc:latest'

Now i have been asked to use same EC2 to create pipeline for production environment which is different AWS account.I understand that i can create a cross-account role to get required permission to push images.

But my concern is how to create a docker login url for production account in Dev account's EC2 ? As in "aws ecr get-login --no-include-email --region us-east-1" we don't specify account so it will always generate for dev account.

Upvotes: 0

Views: 1117

Answers (1)

akskap
akskap

Reputation: 823

aws ecr cli command has an option for specifying the registry-id with --registry-ids option. That could be used to enable temporary access in order to be able to push/pull multiple ECR registries

More details can be found at:

Upvotes: 1

Related Questions