How can one achieve the boto 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
noregionerror: you must specify a region error. The fix is you must specify a region. The quickest fix is to open your ~/. aws/config and add region=us-east-1 to the [default] profile.
class boto3.session. Session (aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, region_name=None, botocore_session=None, profile_name=None)[source] A session stores configuration state and allows you to create service clients and resources.
Waiters: In the case of Boto3, there are some requests which are not instant. One such example is when you try to start or stop any instance. For such kinds of requests, you can initiate those requests and check back at some later time.
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With