Diagnose deploy workflow failure by surfacing cross-account ECR mismatch#346
Diagnose deploy workflow failure by surfacing cross-account ECR mismatch#346
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23b6a3c6ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| PROMOTED_IMAGE_TAG="promoted-${GITHUB_SHA}" | ||
| TARGET_IMAGE_URI="${AWS_ACCOUNT_ID}.dkr.ecr.${{ vars.AWS_REGION || 'us-east-1' }}.amazonaws.com/${TARGET_REPOSITORY_NAME}:${PROMOTED_IMAGE_TAG}" | ||
|
|
||
| if [ "$SOURCE_ACCOUNT_ID" != "$AWS_ACCOUNT_ID" ]; then |
There was a problem hiding this comment.
Don't fail promotion when source and target accounts differ
This new guard unconditionally exits when SOURCE_ACCOUNT_ID and AWS_ACCOUNT_ID differ, but the repository’s documented deployment model explicitly supports stage-to-prod promotion across separate AWS accounts (see README.md lines 180-194 and 234-240, which require granting the prod role pull access to stage ECR). In that supported configuration, cross-account ECR pull is expected behavior, so this check converts a valid multi-account deployment into a guaranteed failure before docker pull runs.
Useful? React with 👍 / 👎.
Motivation
Deploy CDK Stackrun failed in thedeploy (prod-us-east)job at thePromote Tested Image Into Production ECRstep.AWS_ACCOUNT_IDcredentials but the tested image URI points at a different account, causing ECR login/pull to fail.Description
SOURCE_ACCOUNT_IDfrom the tested image URI by parsingSOURCE_REGISTRYin thePromote Tested Image Into Production ECRstep.SOURCE_ACCOUNT_IDtoAWS_ACCOUNT_IDand fails early with a clear diagnostic message when they differ..github/workflows/deploy.ymlso the workflow surfaces account-mismatch problems before attemptingdocker pull/docker login.Testing
curland parsed jobs with a short Python script to confirm the failing step wasPromote Tested Image Into Production ECR.SOURCE_ACCOUNT_IDextraction and guard usinggit diffand by printing the updated lines withnl -ba .github/workflows/deploy.yml | sed -n '210,270p'.Codex Task