1
votes

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
What does your ~/.aws/config file look like? Do you have the same result when you include --region eu-west-1 in your aws cli?ThomasVdBerge
I've edited the question to include this - the only setting is region = eu-west-1Nathan
And does it work if you add --region eu-west-1 in your aws cli command?ThomasVdBerge
Yes - question updated again. Adding --region is the workaround I've been using for now until I solve this.Nathan
And does it work by setting the ENV var? export AWS_DEFAULT_REGION=eu-west-1 Seems like your config file is not readable, but since aws configure get region works, that seems strange. (or there is a bug in the aws cli itself. What version of aws cli are you on?)ThomasVdBerge

1 Answers

4
votes

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.