I want to list the ec2
instances in aws account with boto module.I am getting the issue as
"You must specify a region".Here is the program.
import boto3
ec2 = boto3.resource('ec2')
for instance in ec2.instances.all()
print instance.id, instance.state
I didn't specify any default region. How can I specify it programmatically ?
Since you are using the resource interface, your code will look like this:
import boto3
ec2 = boto3.resource('ec2', region_name = 'us-west-2')
for instance in ec2.instances.all()
print instance.id, instance.state
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