Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rb:aws-cli [18/12/2018 14:20]
andrew [Initial install]
rb:aws-cli [07/02/2019 09:27] (current)
andrew [Using roles and profiles with Boto3]
Line 115: Line 115:
 </​code>​ </​code>​
  
 +
 +===== Using roles and profiles with Boto3 =====
 +
 +''​boto3''​ is Amazon'​s python library to interface with the aws cli commands.
 +
 +A client needs to be set up, and for local cli usage, this needs to be linked with a profile as set above.
 +
 +<code python>
 +#​!/​usr/​bin/​env python
 +
 +import boto3
 +
 +profile = '​nonprod_admin'​
 +
 +# Create ec2 client
 +session = boto3.session.Session(profile_name=profile)
 +ec2 = session.client('​ec2'​)
 +
 +# Create SQS client
 +session = boto3.session.Session(profile_name=profile)
 +sqs = session.client('​sqs'​)
 +
 +</​code>​
 +
 +This client (ec2, sqs etc) can be used to set or retreive information as the user in the profile:-
 +
 +<code python>
 +AMIResponse = ec2.describe_images(Filters=[{'​Name':​ '​name',​ '​Values':​ [Regex]}, ], Owners=['​self'​])
 +</​code>​
  
 ===== AWS CodeCommit ===== ===== AWS CodeCommit =====

rb/aws-cli.1545142826.txt.gz ยท Last modified: 18/12/2018 14:20 by andrew