Skip to content

Commit c66a973

Browse files
committed
Enh(aws): Check account id
1 parent 55f8999 commit c66a973

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

aws/setup/docker/build_and_push_aws.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ if [ -z "${GITHUB_TOKEN:-}" ]; then
5555
exit 1
5656
fi
5757

58+
# Verify AWS account identity
59+
echo -e "${YELLOW}Checking AWS account identity...${NC}"
60+
CURRENT_ACCOUNT=$(aws sts get-caller-identity --query Account --output text 2>/dev/null || echo "unknown")
61+
EXPECTED_ACCOUNT=$(echo $ECR_REGISTRY | cut -d'.' -f1)
62+
if [ "$CURRENT_ACCOUNT" != "$EXPECTED_ACCOUNT" ]; then
63+
echo -e "${RED}ERROR: Your current AWS account ($CURRENT_ACCOUNT) does NOT match the target ECR account ($EXPECTED_ACCOUNT)!${NC}"
64+
exit 1
65+
fi
66+
echo -e "${GREEN}✓ AWS account matches target ECR account${NC}"
67+
5868
# Build the Docker image
5969
echo -e "${YELLOW}Building Docker image...${NC}"
6070
FULL_IMAGE_NAME="$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"

0 commit comments

Comments
 (0)