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,852
  • 9
  • 51
  • 69

1 Answers1

18

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
  • 7,141
  • 5
  • 42
  • 64
Sujil Maharjan
  • 1,307
  • 10
  • 12