AWS CLI executing in wrong regions

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 03:14:11

问题


My AWS profile is configured to default to eu-west-1, however when I run an AWS CLI command, it is executing in us-east-1:

>aws configure get region
eu-west-1

>aws events put-rule --name hourly_trigger --schedule-expression "rate(60 minutes)"
{ 
  "RuleArn": "arn:aws:events:us-east-1:588237033746:rule/hourly_trigger"
}

I've looked into profiles and config options and can't determine why this is. My profile is set as follows:

[default]
region = eu-west-1

And this command works in the intended region if I add --region

>aws events put-rule --name hourly_trigger --schedule-expression "rate(60 mi
nutes)" --region eu-west-1
{
    "RuleArn": "arn:aws:events:eu-west-1:588237033746:rule/hourly_trigger"
}

回答1:


AWS Region is obtained through three ways:

  1. Checks if your command contains --region
  2. If not specified, Checks the env variable AWS_DEFAULT_REGION
  3. If that is not set, it checks the region defined in the ~/.aws/config file

Make sure AWS_DEFAULT_REGION is not set. Then it should automatically use the region defined in the config file.



来源:https://stackoverflow.com/questions/51286425/aws-cli-executing-in-wrong-regions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!