13

How can one achieve the command:

boto.ec2.connect_to_region()

using the boto3 suite? It seems not to be at a glance in the docs

I guess it's a simpler and more precise question than the extense answer you can find in the following post.

Thanks for any help

Evhz
  • 8,191
  • 8
  • 46
  • 65

1 Answers1

16

boto3 wants you to specify the region by default. So, the solutions for you in Python is:

>>> import boto3
>>> boto_client = boto3.client('ec2', region_name='us-west-2')

You can also set up a default region. In order to do so:

>>> import boto3
>>> boto_client = boto3.setup_default_session(region_name='us-west-2')
>>> boto_client = boto3.client('ec2')
Nevermore
  • 6,741
  • 4
  • 35
  • 61
Sujil Maharjan
  • 1,177
  • 9
  • 12