-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get-ecr-uri.sh falls back to use another region in partition if regio…
…n unconfigured
- Loading branch information
Showing
2 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
echo "--> Should use specified account when passed in" | ||
EXPECTED_ECR_URI="999999999999.dkr.ecr.mars-west-1.aws-mars" | ||
REGION="mars-west-1" | ||
PARTITION="aws-mars" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}" "999999999999") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should use account mapped to the region when set" | ||
EXPECTED_ECR_URI="590381155156.dkr.ecr.eu-south-1.aws" | ||
REGION="eu-south-1" | ||
PARTITION="aws" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should use non-opt-in account when not opt-in-region" | ||
EXPECTED_ECR_URI="602401143452.dkr.ecr.us-east-2.aws" | ||
REGION="us-east-2" | ||
PARTITION="aws" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should use us-west-2 account and region when opt-in-region" | ||
EXPECTED_ECR_URI="602401143452.dkr.ecr.us-west-2.aws" | ||
REGION="eu-south-100" | ||
PARTITION="aws" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should default us-gov-west-1 when unknown aws-us-gov region" | ||
EXPECTED_ECR_URI="013241004608.dkr.ecr.us-gov-west-1.aws-us-gov" | ||
REGION="us-gov-east-100" | ||
PARTITION="aws-us-gov" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should default cn-northwest-1 when unknown aws-cn region" | ||
EXPECTED_ECR_URI="961992271922.dkr.ecr.cn-northwest-1.aws-cn" | ||
REGION="cn-north-100" | ||
PARTITION="aws-cn" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should default us-iso-east-1 when unknown aws-iso region" | ||
EXPECTED_ECR_URI="725322719131.dkr.ecr.us-iso-east-1.aws-iso" | ||
REGION="us-iso-west-100" | ||
PARTITION="aws-iso" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi | ||
|
||
echo "--> Should default us-isob-east-1 when unknown aws-isob region" | ||
EXPECTED_ECR_URI="602401143452.dkr.ecr.us-west-2.aws-isob" | ||
REGION="us-isob-west-100" | ||
PARTITION="aws-isob" | ||
ECR_URI=$(/etc/eks/get-ecr-uri.sh "${REGION}" "${PARTITION}") | ||
if [ ! "$ECR_URI" = "$EXPECTED_ECR_URI" ]; then | ||
echo "❌ Test Failed: expected ecr-uri=$EXPECTED_ECR_URI but got '${ECR_URI}'" | ||
exit 1 | ||
fi |