Skip to content

Auto-detect AWS Region from Config #2425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 5 additions & 2 deletions hack/e2e/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ mkdir -p "${TEST_DIR}"
CLUSTER_FILE=${TEST_DIR}/${CLUSTER_NAME}.${CLUSTER_TYPE}.yaml
KUBECONFIG=${KUBECONFIG:-"${TEST_DIR}/${CLUSTER_NAME}.${CLUSTER_TYPE}.kubeconfig"}

export AWS_REGION=${AWS_REGION:-us-west-2}
ZONES=${AWS_AVAILABILITY_ZONES:-us-west-2a,us-west-2b,us-west-2c}
# Use AWS_REGION as priority, fallback to region from awscli config, fallback to us-west-2
REGION_FROM_CONFIG="$(aws configure get region || echo '')"
export AWS_REGION=${AWS_REGION:-${REGION_FROM_CONFIG:-us-west-2}}
# If zones are not provided, auto-detect the first 3 AZs that are not opt in
ZONES=${AWS_AVAILABILITY_ZONES:-$(aws ec2 describe-availability-zones | jq -r '[.AvailabilityZones[] | select(.OptInStatus == "opt-in-not-required") | .ZoneName][:3] | join(",")')}
FIRST_ZONE=$(echo "${ZONES}" | cut -d, -f1)
NODE_COUNT=${NODE_COUNT:-3}
INSTANCE_TYPE=${INSTANCE_TYPE:-c5.large}
Expand Down