From 0636ceab716fba404277cb7fd8d75c902093a7b1 Mon Sep 17 00:00:00 2001 From: Rasputin02 Date: Tue, 21 Jul 2026 03:07:02 +0800 Subject: [PATCH] fix(deploy): honor --china by selecting cn-north-1 as the default region The --china flag is documented as deploying to the China region, and deploy/README.md shows "./deploy.sh --china --init-data" as the China one-liner. However the flag set REGION="${REGION:-cn-north-1}", and REGION is always already populated from AWS_DEFAULT_REGION or the us-east-1 default, so the parameter expansion never took effect. Running "./deploy.sh --china" therefore printed "China region mode: us-east-1" and deployed to us-east-1 with the China-only Bedrock model IDs and a non-China ECR domain. --china now sets cn-north-1 after argument parsing, and only when --region was not passed explicitly, so an explicit --region still wins regardless of flag order. Also replaces the fixed-offset "head -14 | tail -12" --help output, which truncated --destroy and --help, with a sed range over the banner block, and documents the existing but unlisted --key option. --- deploy/deploy.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 9cfd62e..e437484 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -11,6 +11,7 @@ set -euo pipefail # --china Deploy to China region (cn-north-1) # --stack NAME Stack name (default: agentic-data) # --instance TYPE EC2 instance type (default: t4g.medium) +# --key NAME EC2 key pair name (optional, enables SSH) # --init-data Upload sample data after deploy # --destroy Delete the stack # --help Show this help @@ -19,6 +20,7 @@ set -euo pipefail # Defaults MODE="EC2" REGION="${AWS_DEFAULT_REGION:-us-east-1}" +REGION_EXPLICIT="" STACK_NAME="agentic-data" INSTANCE_TYPE="t4g.medium" CHINA="" @@ -32,20 +34,26 @@ KEY_PAIR="" while [[ $# -gt 0 ]]; do case $1 in --mode) MODE="${2^^}"; shift 2 ;; - --region) REGION="$2"; shift 2 ;; - --china) CHINA="true"; REGION="${REGION:-cn-north-1}"; shift ;; + --region) REGION="$2"; REGION_EXPLICIT="true"; shift 2 ;; + --china) CHINA="true"; shift ;; --stack) STACK_NAME="$2"; shift 2 ;; --instance) INSTANCE_TYPE="$2"; shift 2 ;; --key) KEY_PAIR="$2"; shift 2 ;; --init-data) INIT_DATA="true"; shift ;; --destroy) DESTROY="true"; shift ;; --help) - head -14 "$0" | tail -12 + # Print the usage block delimited by the two "# ===" banner rules + sed -n '/^# ===/,/^# ===/p' "$0" | sed '1d;$d' exit 0 ;; *) echo "Unknown option: $1"; exit 1 ;; esac done +# --china selects the default China region, unless --region was given explicitly +if [[ "$CHINA" == "true" ]] && [[ -z "$REGION_EXPLICIT" ]]; then + REGION="cn-north-1" +fi + # China region adjustments if [[ "$CHINA" == "true" ]] || [[ "$REGION" == cn-* ]]; then CHINA="true"