aws / aws/aws-cdk

aws-cdk: Docker logout after deployment

Open
#31,943 3 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecr feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When using aws-cdk with other tools (e.g. serverless in a monorepo), using a docker deployment artifact that uses ECR to upload, the aws-cdk stays signed in with the created role for ECR (CustomCDKECRDeployment role). This causes issues when using other tools, that use a different ECR repository. They detect that docker is signed into the https://.dkr.ecr.eu-central-1.amazonaws.com repository, and don't login themselves. But the CustomCDKECRDeployment role is to restricted to use this login.

So it's best to logout after the CDK deployment process is done. This can be done with a ```docker logout https://.dkr.ecr.eu-central-1.amazonaws.com```.

I've also opened a ticket in the serverless project to do the same, so there is no conflict.

Related
https://github.com/serverless/serverless/issues/12895

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

Logout to ECR(s) when done with deployment

### Current Behavior

Stays logged in after deployment.

### Reproduction Steps

Do a deployment with an docker asset that pushed to ECR repo.
Try to push a docker image to another repository in the same account manually, or with another framework like serverless, without docker logout. This will not work, because the system is still logged in with the CustomCDKECRDeployment role.

### Possible Solution

Logout out of the ECR(s) with ```docker logout https://.dkr.ecr.eu-central-1.amazonaws.com```

### Additional Information/Context

_No response_

### CDK CLI Version

2.143.0

### Framework Version

_No response_

### Node.js Version

node 22

### OS

macos

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

No source file or test is named in the issue. Start by tracing the aws-cdk Docker asset deployment path that authenticates to ECR, then inspect how deployment completion and failures are handled. Done means an ECR Docker login is cleaned up after deployment without breaking artifact uploads or other deployment tools.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, typescript
Domain
cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.