aws / aws/aws-cdk

Unable to push to ContainerAssetsRepository when using a trusted account to deploy

Open
#30,400 4 comments 0 reactions 0 assignees View on GitHub
bug effort/small p3 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I've boostrapped my account with the following settings:
```
cdk bootstrap --trust --trust-for-lookup --cloudformation-execution-policies 'arn:aws:iam::aws:policy/AdministratorAccess' aws:///eu-central-1
```

I get this error when i'm logged in with my trusted account to deploy a stack

```
fail: docker push .dkr.ecr.eu-central-1.amazonaws.com/cdk-hnb659fds-container-assets--eu-central-1:
exited with error code 1: denied: User: arn:aws:sts:::assumed-role// is not authorized
to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr:eu-central-1::repository/cdk-hnb659fds-container-assets--eu-central-1
because no resource-based policy allows the ecr:InitiateLayerUpload action
```

### Expected Behavior

I should be able to push an docker image asset to the ContainerAssetsRepository from a trusted account.

### Current Behavior

Not supported, error shown

### Reproduction Steps

1. Bootstrap
```
cdk bootstrap --trust --trust-for-lookup --cloudformation-execution-policies 'arn:aws:iam::aws:policy/AdministratorAccess' aws:///eu-central-1
```
2. Stack with DockerImageAsset from aws-cdk-lib/aws-ecr-assets
3. Login with trusted account
4. cdk deploy

### Possible Solution

Can be fixed by adding the trusted account(s) to the ContainerAssetsRepository policy

### Additional Information/Context

_No response_

### CDK CLI Version

2.143.0

### Framework Version

_No response_

### Node.js Version

20

### OS

macos

### Language

TypeScript

### Language Version

TypeScript (5.4.5)

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the `cdk bootstrap --trust` flow and the ContainerAssetsRepository policy generated for the bootstrap stack. Reproduce the DockerImageAsset deployment using the listed bootstrap command and trusted-account login, then verify that the resulting ECR policy permits the trusted account's image push actions.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, typescript
Domain
cloud, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.