I recently needed to be able to use the AWS CLI for managing AWS resources in
China’s Beijing Region. It took a little bit more than a simple Google search,
so I thought I’d write a quick post on it. In addition, I still wanted to use
the AWS CLI to manage resources in the us-west-2
region as well.
My searching eventually led me to AWS Named Profiles. After another few
minutes of searching, I finally found the region abbreviation for Beijing,
cn-north-1
. Anyways, I’ve copied some of the config files in the Named
Profile example and modified them to more accurately reflect my config:
~/.aws/credentials
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[china]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
~/.aws/config
[default]
region = us-west-2
output = text
s3 =
signature_version = s3v4
[preview]
cloudfront = true
[profile china]
region = cn-north-1
output = text
See the previously mentioned documentation on AWS Named Profiles for more details. Getting a list of running EC2 instances in Beijing was now as simple as:
aws ec2 describe-instances --profile china