Creating a lambda client as shown in the documentation:
import boto3
client = boto3.client('lambda')
results in the following error:
botocore.exceptions.NoRegionError: You must specify a region.
botocore 1.2.10
boto3 1.1.4
Yes and no. The client(...) will automatically pick up the region for you, if you define it in your configuration file (among other sources).
Try put something like this in your ~/.aws/config
[default]
region = us-west-2
Normally it is already setup if you install AWS CLI and configure it.
Is there a way to tell boto3 to use a specific region when running a script, other than to configure the whole user to use that region? We run this on our CI server, and we have many jobs running concurrently, that need to talk to different regions, so configuring it through a global configuration file is going to be complicated. The documentation doesn't show any alternative way of doing it, that I could find.
@lewisd32 yes you can specify a specific region. You do so by passing in region_name as a **kwargs style argument to your client call.
In your case, it would be:
import boto3
client = boto3.client('lambda',region_name='us-west-2')
You can also specify a number of other arguments:
http://boto3.readthedocs.org/en/latest/reference/core/session.html#boto3.session.Session.client
Most helpful comment
@lewisd32 yes you can specify a specific region. You do so by passing in region_name as a **kwargs style argument to your client call.
In your case, it would be:
import boto3client = boto3.client('lambda',region_name='us-west-2')You can also specify a number of other arguments:
http://boto3.readthedocs.org/en/latest/reference/core/session.html#boto3.session.Session.client