@shinyaz

AgentCore CLI AWS_REGION environment variable overrides aws-targets.json region

1 min read

Set "region": "us-east-1" in aws-targets.json, ran agentcore deploy, and the stack ended up in ap-northeast-1. The culprit was AWS_REGION=ap-northeast-1 in my shell environment.

AgentCore CLI uses CDK internally, and CDK can pick up AWS_REGION over the region specified in aws-targets.json.

Terminal
# Stack was in the wrong region
aws cloudformation describe-stacks \
  --stack-name AgentCore-MyProject-default \
  --region ap-northeast-1 \
  --query 'Stacks[0].StackStatus' --output text
# => CREATE_COMPLETE (expected us-east-1)

Fix by aligning the env var or unsetting it:

Terminal
export AWS_REGION=us-east-1
# or
unset AWS_REGION

This behavior isn't documented in the CLI docs. Especially important when using region-limited features like Evaluator.

Share this post

Shinya Tahara

Shinya Tahara

Solutions Architect @ AWS

I'm a Solutions Architect at AWS, providing technical guidance primarily to financial industry customers. I share learnings about cloud architecture and AI/ML on this site.The views and opinions expressed on this site are my own and do not represent the official positions of my employer.