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

Nicolas
preguntada hace 2 meses158 visualizaciones
2 Respuestas
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
EXPERTO
respondido hace 2 meses
profile picture
EXPERTO
revisado hace 2 meses
  • 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
respondido hace un mes

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas