I have Jenkins Slave node as EC2 instance where i am running my CI/CD and pushing image to AWS ECR.
stage('Push Image to ECR'){
steps{
withAWS(region: 'us-east-1', roleAccount: shared_services_account, role:
'Role-Name') {
sh 'eval \$(aws ecr get-login --no-include-email --region us-east-1)'
sh 'docker tag test-image 5722XXXXXX.dkr.ecr.us-east-
1.amazonaws.com/Dev/DC/DCservice:latest'
sh 'sudo docker push 572205XXXX.dkr.ecr.us-east-
1.amazonaws.com/Dev/DC/DCservice:latest'
}
Now here my EC2 Jenkins slave node and ECR are in same account.
But for production if want to use same Jenkins EC2 slave node and push it to ECR of production AWS account.
I believe the code below will not work as it will push to ECR of same AWS account ?
sh 'eval \$(aws ecr get-login --no-include-email --region us-east-1'
Please suggest how can i push to ECR of prod AWS account using the same EC2 slave node.