Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,17 @@ jobs:
fi

SOURCE_REGISTRY="${SOURCE_IMAGE_URI%%/*}"
SOURCE_ACCOUNT_ID="${SOURCE_REGISTRY%%.*}"
TARGET_REPOSITORY_NAME="cdk-hnb659fds-container-assets-${AWS_ACCOUNT_ID}-${{ vars.AWS_REGION || 'us-east-1' }}"
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

echo "Image promotion is running with AWS account ${AWS_ACCOUNT_ID}, but the tested image lives in account ${SOURCE_ACCOUNT_ID}." >&2
echo "This account mismatch causes ECR pull/login failures without explicit cross-account access or a stage-account credential step." >&2
exit 1
fi

aws ecr get-login-password --region "${{ vars.AWS_REGION || 'us-east-1' }}" | \
docker login --username AWS --password-stdin "$SOURCE_REGISTRY"

Expand Down
Loading