fix(deploy): --china flag never selects a China region - #2
Open
Rasputin02 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
deploy/deploy.sh:36implements the--chinaflag as:REGIONis unconditionally assigned atdeploy/deploy.sh:21asREGION="${AWS_DEFAULT_REGION:-us-east-1}", so by the time argument parsing runs it is never empty.${REGION:-cn-north-1}is therefore always a no-op, and--chinanever actually selects a China region.This matters because
deploy/README.md:76documents./deploy.sh --china --init-dataas the China deployment one-liner — following the README as written deploys to the wrong partition.Concrete failure
With
AWS_DEFAULT_REGIONunset and a stubbedaws sts get-caller-identity:So
--chinaalone silently targetsus-east-1while switchingSUP_MODEL/SUB_MODELto the China Bedrock model IDs (anthropic.claude-3-sonnet-20240229-v1:0/haiku) and building a.amazonaws.comECR domain instead of.amazonaws.com.cn. The result is a global-partition stack configured with model IDs that do not exist there.What the fix does
--chinacase and applies the region default after the parse loop.--regionwas passed explicitly (REGION_EXPLICIT) so an explicit--regionstill wins over--chinaregardless of flag order../deploy.sh --china --region cn-northwest-1and./deploy.sh --region cn-northwest-1 --chinaboth resolve tocn-northwest-1.Two small related fixes in the same argument-handling block:
--helpusedhead -14 "$0" | tail -12, a fixed line offset that printed lines 3-14 and cut off the last two documented options (--destroyand--help). Replaced with asedrange over the two# ===banner rules, so the help output stays correct as options are added.--key NAMEoption to the usage block; it is implemented atdeploy/deploy.sh:38but was never documented.How I verified
Ran inside a container against the checked-out tree, with a stub
awsonPATHreturning a dummy account ID so the script reaches the banner, andAWS_DEFAULT_REGIONunset:main(output above).Region:andImage:lines for:--china->cn-north-1+.amazonaws.com.cn;--china --region cn-northwest-1->cn-northwest-1;--region cn-northwest-1 --china->cn-northwest-1;--region ap-southeast-1->ap-southeast-1+.amazonaws.com; no args ->us-east-1+.amazonaws.com.bash -n deploy/deploy.shpasses.--helpnow lists all nine options including--key,--destroyand--help.What I could not verify
I did not run a real deployment — no AWS credentials for either partition, so ECR push,
cloudformation deploy, and the actual China Bedrock model behaviour are untested end to end. Verification covers the argument parsing and the region/ECR-domain values the script derives from it.shellcheckwas not available in my environment, so the change is only syntax-checked withbash -n.