Interview Prep/Python for DevOps/boto3 & AWS automation

How does boto3 decide the region, and what is the gotcha with `AWS_REGION`?

AdvancedConceptboto3 & AWS automation
Answer

Order: explicit region_name, then AWS_DEFAULT_REGION, then the region in the active profile in ~/.aws/config. boto3 does not read AWS_REGION (that is the variable the Lambda runtime and several other AWS SDKs use), so scripts that set only AWS_REGION failed with botocore.exceptions.NoRegionError: You must specify a region. In CI, aws-actions/configure-aws-credentials sets both. Our habit: pass region_name explicitly for multi-region code, and set AWS_DEFAULT_REGION for single-region scripts.

All Python for DevOps questions Roadmap: Python for automation

More on boto3 & AWS automation