diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 0d0773f63..cbd699916 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -96,3 +96,14 @@ source_profile = source-profile-name region = us-east-1 output = json ``` + +## NOTES +1. If we see an issue with a `aws` CLI command for a specific region e.g: + ```shell + $ aws eks list-clusters --region me-central-1 + An error occurred (UnrecognizedClientException) when calling the ListClusters operation: The security token included in the request is invalid + ``` + Ensure you're fetching the AWS credentials from a regional STS endpoint i.e: + ```shell + $ AWS_STS_REGIONAL_ENDPOINTS=regional gimme-aws-creds + ``` diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 0c43031df..d6484aace 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -43,6 +43,15 @@ function asp() { export AWS_EB_PROFILE=$1 export AWS_PROFILE_REGION=$(aws configure get region) + if [[ -z "${AWS_PROFILE_REGION}" ]]; then + if [[ -z "${available_profiles[(r)default]}" ]]; then + echo "region defaulting to us-east-1" + export AWS_PROFILE_REGION=us-east-1 + else + export AWS_PROFILE_REGION=$(aws configure get region --profile default) + fi + fi + export AWS_REGION=$AWS_PROFILE_REGION _aws_update_state