Skip to content

Commit f573813

Browse files
committed
Standardize region handling for Global Accelerator
1 parent 6b8688b commit f573813

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tuts/145-aws-globalaccelerator-gs/aws-globalaccelerator-gs.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
WORK_DIR=$(mktemp -d); exec > >(tee -a "$WORK_DIR/ga.log") 2>&1
3-
export AWS_DEFAULT_REGION=us-west-2; echo "Region: us-west-2 (Global Accelerator)"
3+
REGION=us-west-2 # Global Accelerator requires us-west-2
4+
export AWS_DEFAULT_REGION="$REGION"; export AWS_REGION="$REGION"; echo "Region: $REGION (Global Accelerator)"
45
RANDOM_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8 | head -n 1); GA_NAME="tut-ga-${RANDOM_ID}"
56
handle_error() { echo "ERROR on line $1"; trap - ERR; cleanup; exit 1; }; trap 'handle_error $LINENO' ERR
67
cleanup() { echo ""; echo "Cleaning up..."; [ -n "$GA_ARN" ] && { aws globalaccelerator update-accelerator --accelerator-arn "$GA_ARN" --no-enabled 2>/dev/null; sleep 5; aws globalaccelerator delete-accelerator --accelerator-arn "$GA_ARN" 2>/dev/null && echo " Deleted accelerator"; }; rm -rf "$WORK_DIR"; echo "Done."; }

0 commit comments

Comments
 (0)