Run-instances in another region without changing aws configuration

216 Views Asked by At

I would like to run an EC2 in another region without having to change aws configuration. This is a script that should run for other users as well. I know that it is possible to create an SG in another region just by passing the argument --region us-east-2 .. but doesn't work for Runinstances api.

Another solution would be a script that runs aws configure and change ONLY the region, without any input from the user. any idea on how to implement any of these 2 ?

1

There are 1 best solutions below

3
Mark B On

--region works for all aws cli commands. It is a top-level parameter documented here. If that isn't working for you, you should show the details of that in your question.

Also, aws configure only sets the default region. You can override the current region at any time by setting the AWS_REGION environment variable. You could do this inside your script before calling aws cli commands.

See the aws cli environment variable documentation.