Created
November 22, 2016 08:29
-
-
Save pawneetdev/7889a354bf7dc1c29412f7dfe9e51083 to your computer and use it in GitHub Desktop.
AWS SDK boto3 python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# Getting started ################## | |
1.) pip install boto3 | |
2.) Create credentials file at ~/.aws/credentials | |
[default] | |
aws_access_key_id = YOUR_ACCESS_KEY | |
aws_secret_access_key = YOUR_SECRET_KEY | |
3.) Create config file at ~/.aws/config | |
[default] | |
region=us-east-1 | |
#################################################### | |
import boto3 | |
#### List all buckets in S3 #### | |
s3 = boto3.resource('s3') | |
for bucket in s3.buckets.all(): | |
print bucket.name | |
################################ | |
######## List all EC2 instances in a region ######## | |
ec2 = boto3.resource('ec2', region_name='us-west-2') | |
for instance in ec2.instances.all(): | |
print instance, instance.tags | |
#################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment