Skip to content

Commit bfb6e11

Browse files
committed
support additional ECR account IDs
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 591e8d7 commit bfb6e11

5 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎.github/workflows/bake.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,8 @@ jobs:
892892
name: Login to Amazon ECR
893893
if: ${{ needs.registry-identities.outputs.aws-ecr-enabled == 'true' }}
894894
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
895+
env:
896+
AWS_ACCOUNT_IDS: ${{ needs.registry-identities.outputs.aws-ecr-account-ids }}
895897
with:
896898
registry-auth: |
897899
- registry: ${{ needs.registry-identities.outputs.aws-ecr-registry }}
@@ -1144,6 +1146,8 @@ jobs:
11441146
name: Login to Amazon ECR
11451147
if: ${{ inputs.push && inputs.output == 'image' && needs.registry-identities.outputs.aws-ecr-enabled == 'true' }}
11461148
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
1149+
env:
1150+
AWS_ACCOUNT_IDS: ${{ needs.registry-identities.outputs.aws-ecr-account-ids }}
11471151
with:
11481152
registry-auth: |
11491153
- registry: ${{ needs.registry-identities.outputs.aws-ecr-registry }}

‎.github/workflows/build.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ jobs:
792792
name: Login to Amazon ECR
793793
if: ${{ needs.registry-identities.outputs.aws-ecr-enabled == 'true' }}
794794
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
795+
env:
796+
AWS_ACCOUNT_IDS: ${{ needs.registry-identities.outputs.aws-ecr-account-ids }}
795797
with:
796798
registry-auth: |
797799
- registry: ${{ needs.registry-identities.outputs.aws-ecr-registry }}
@@ -1040,6 +1042,8 @@ jobs:
10401042
name: Login to Amazon ECR
10411043
if: ${{ inputs.push && inputs.output == 'image' && needs.registry-identities.outputs.aws-ecr-enabled == 'true' }}
10421044
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
1045+
env:
1046+
AWS_ACCOUNT_IDS: ${{ needs.registry-identities.outputs.aws-ecr-account-ids }}
10431047
with:
10441048
registry-auth: |
10451049
- registry: ${{ needs.registry-identities.outputs.aws-ecr-registry }}

‎.github/workflows/setup-registry-identities.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ on:
2525
aws-ecr-region:
2626
description: "AWS region to use for ECR authentication"
2727
value: ${{ jobs.setup-registry-identities.outputs.aws-ecr-region }}
28+
aws-ecr-account-ids:
29+
description: "Additional AWS account IDs to authenticate against"
30+
value: ${{ jobs.setup-registry-identities.outputs.aws-ecr-account-ids }}
2831
gcp-wif-enabled:
2932
description: "Whether a GCP Workload Identity Federation registry identity was configured"
3033
value: ${{ jobs.setup-registry-identities.outputs.gcp-wif-enabled }}
@@ -74,6 +77,7 @@ jobs:
7477
aws-ecr-registry: ${{ steps.validate.outputs.aws-ecr-registry }}
7578
aws-ecr-role-to-assume: ${{ steps.validate.outputs.aws-ecr-role-to-assume }}
7679
aws-ecr-region: ${{ steps.validate.outputs.aws-ecr-region }}
80+
aws-ecr-account-ids: ${{ steps.validate.outputs.aws-ecr-account-ids }}
7781
gcp-wif-enabled: ${{ steps.validate.outputs.gcp-wif-enabled }}
7882
gcp-wif-registry: ${{ steps.validate.outputs.gcp-wif-registry }}
7983
gcp-wif-workload-identity-provider: ${{ steps.validate.outputs.gcp-wif-workload-identity-provider }}
@@ -136,6 +140,7 @@ jobs:
136140
core.setOutput('aws-ecr-registry', '');
137141
core.setOutput('aws-ecr-role-to-assume', '');
138142
core.setOutput('aws-ecr-region', '');
143+
core.setOutput('aws-ecr-account-ids', '');
139144
core.setOutput('gcp-wif-enabled', 'false');
140145
core.setOutput('gcp-wif-registry', '');
141146
core.setOutput('gcp-wif-workload-identity-provider', '');
@@ -179,6 +184,7 @@ jobs:
179184
core.setOutput('aws-ecr-registry', awsEcr?.registry || '');
180185
core.setOutput('aws-ecr-role-to-assume', awsEcr?.roleToAssume || '');
181186
core.setOutput('aws-ecr-region', awsEcr?.region || '');
187+
core.setOutput('aws-ecr-account-ids', awsEcr?.accountIDs || '');
182188
core.setOutput('gcp-wif-enabled', gcpWif ? 'true' : 'false');
183189
core.setOutput('gcp-wif-registry', gcpWif?.registry || '');
184190
core.setOutput('gcp-wif-workload-identity-provider', gcpWif?.workloadIdentityProvider || '');

‎.github/workflows/verify.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ jobs:
127127
name: Login to Amazon ECR
128128
if: ${{ steps.vars.outputs.signed == 'true' && steps.vars.outputs.output-type == 'image' && needs.registry-identities.outputs.aws-ecr-enabled == 'true' }}
129129
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
130+
env:
131+
AWS_ACCOUNT_IDS: ${{ needs.registry-identities.outputs.aws-ecr-account-ids }}
130132
with:
131133
registry-auth: |
132134
- registry: ${{ needs.registry-identities.outputs.aws-ecr-registry }}

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ jobs:
514514
registry: 123456789100.dkr.ecr.us-east-1.amazonaws.com
515515
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
516516
region: us-east-1
517+
account_ids: 123456789101,123456789102
517518
```
518519

519520
| Name | Type | Required | Description |
@@ -522,11 +523,17 @@ jobs:
522523
| `registry` | String | Yes | Registry server passed to `docker/login-action`, such as `public.ecr.aws` for public ECR or a private ECR host for private ECR. |
523524
| `role-to-assume` | String | Yes | IAM role ARN assumed through GitHub OIDC. |
524525
| `region` | String | Yes | AWS region passed to `aws-actions/configure-aws-credentials` when assuming the role. Use `us-east-1` for ECR Public. |
526+
| `account_ids` | String | No | Comma-separated additional private ECR account IDs to log in to with the assumed role. |
525527

526528
The `registry` value is required for AWS ECR. Use the registry server that
527529
`docker/login-action` should log in to, such as `public.ecr.aws` for public ECR
528530
or `123456789100.dkr.ecr.us-east-1.amazonaws.com` for private ECR.
529531

532+
The account ID in the private ECR registry is always included. Set `account_ids`
533+
to log in to additional accounts in the same region. The assumed role must have
534+
permission to retrieve authorization tokens for those accounts. This setting
535+
does not apply to ECR Public.
536+
530537
#### Google Artifact Registry
531538

532539
Google Artifact Registry authentication is configured with `type: gcp-wif`.

0 commit comments

Comments
 (0)