Need to create ECR and to push image using CDK

0

Hello, I have the following shell script:

...
#
# Get a temporary access password to the AWS ECR (Elastic Container Registry) service
#
aws ecr get-login-password > login-password.txt
#
# Login to the AWS ECR service as generic AWS user
#
docker login -u AWS --password-stdin <login-password.txt https://${ACCOUNT_NUMBER}.dkr.ecr.eu-west-3.amazonaws.com
#
# Create the registry
#
REPO_URI=$(aws ecr create-repository --repository-name $REPO_NAME --output text --query "repository.repositoryUri")
#
# Tag the image
#
docker tag undertow $REPO_URI
#
# Push it
#
#docker push $REPO_URI
...

I need to implement the same using CDK, in Java. I know how to create repositories, etc. but what I don't know and not able to find anywhere is how to get the temporary access password and how to login to ECR, as shown above. Where could I find the missing know how ?

Many thanks in advance foe any help and support.

Nicolas

2 Answers
1

You can achieve that via this: https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ecr_assets/README.html

Or in combination of pipelines as code pipeline that can then execute a shell script, though a bit more manual: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.ShellStep.html

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • My question, if you've read it before answering to it, was related of how to get a temporary access password and login to ECR, using the CDK in Java ? The links you've posted above don't have anything to do with my question.

0

Anyone please ?

Nicolas
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions