Reputation: 27
I am not able to connect to to any region using boto3 i have tried everything using boto3.session.Session, connection = ec2.connect_to_region
connection=ec2.connect_to_region('region_name',aws_access_key_id='',aws_secret_access_key=''
I am getting the below error:
File "/usr/local/lib/python2.7/site-packages/botocore/regions.py", line 135, in _endpoint_for_partition raise NoRegionError() botocore.exceptions.NoRegionError: You must specify a region.
Upvotes: 1
Views: 2563
Reputation: 81454
Your code should look like this:
import boto
conn = boto.ec2.connect_to_region("us-west-2",
aws_access_key_id='<aws access key>',
aws_secret_access_key='<aws secret key>')
However, I recommend that you drop using boto and switch to boto3 unless you have a technical reason.
import boto3
client = boto3.client(
'ec2',
aws_access_key_id='<aws access key>',
aws_secret_access_key='<aws secret key>',
region_name="us-west-2"
Upvotes: 1