p y t h o n b o t o 3 a n d g e t t i n g t h i n g s d o
play

P y t h o n , B o t o 3 , a n d G e t t i n g - PowerPoint PPT Presentation

S n a k e s o n a C l o u d P y t h o n , B o t o 3 , a n d G e t t i n g T h i n g s D o n e We l c o m e B u f f a l o P y t h o n i s t a s ryansb@redhat.com Ryan Scott Brown


  1. S n a k e s o n a C l o u d P y t h o n , B o t o 3 , a n d G e t t i n g T h i n g s D o n e

  2. We l c o m e B u f f a l o P y t h o n i s t a s ryansb@redhat.com Ryan Scott Brown @ryan_sb Senior Software Engineer Ansible by Red Hat

  3. A g e n d a ● Setup & Basics ● Talking to Instances ● In-Application Use ● Ops, Automation, and Hacking the Planet ● Testing (if there’s time)

  4. S e t u p ● Installing ● Credentials/Profiles ● Hello World

  5. I n s t a l l i n g pip install boto3 pip install awscli #optional aws configure --profile testbed #optional

  6. C r e d e n t i a l s # ~/.aws/credentials [testbed] aws_access_key_id = AKIA… aws_secret_access_key = Jhw…

  7. C r e d e n t i a l S o u r c e s ● Instance roles ● Environment variables ● Access/Secret key pair ● Access + secret + session using STS ● Credentials files ● Assuming cross-account roles

  8. I n s t a n c e R o l e s GET http://169.254.169.254/…./credentials Your AWS Backplane Instance Key ID+Secret+Session Token+TTL

  9. C r o s s - A c c o u n t R o l e s AssumeRole arn:aws:….:SuperAdmin Key ID + Secret Your IAM API Client Key ID+Secret+Session Token+TTL

  10. H e l l o Wo r l d aws s3 ls

  11. H e l l o Wo r l d >>> import boto3 >>> s3 = boto3.client(‘s3’) >>> print(s3.list_buckets())

  12. S e s s i o n s ● Typically 1 is plenty ● If you have multi-region or user requirements, these handle it well ● `session.client(‘service’)` works instead of the default `boto3.client(‘service’)`

  13. S 3 D e m o N o t e b o o k Download notebook file Browser-friendly results

  14. C l i e n t s v s . R e s o u r c e s ● Clients are lower-level and usually map 1:1 with APIs ● Resources are built around first-class objects ● Services always have clients, sometimes have resources ● DynamoDB, S3, CloudFormation, and others have both

  15. H i g h L e v e l S e r v i c e s ● App-level services like DynamoDB + S3 ● Accept user uploads ● Generate pre-signed URLs ● Store and query key-value data

  16. D y n a m o D B D e m o N o t e b o o k Download Notebook File Browser-friendly results

  17. C o n n e c t i n g t h e P l a n e t ● What if you combined dataviz with infra data? ● Networkx (graph handling library) can export visual graphs b

  18. E C 2 D e m o N o t e b o o k Download notebook file Browser-friendly results

  19. H a c k i n g t h e P l a n e t ● Python can be used in combination with other tools ● Have a bunch of CloudFormation? No problem – https://github.com/ryansb/yesterdaytabase ● Ansible? Make a module! ● Chef/Puppet? Mix user-data+boto3+Chef Solo/OpsWorks

  20. E x t e n d i n g C l o u d F o r m a t i o n ● AWS Lambda can be used for custom resources – https://github.com/ryansb/acm-certs-cloudformation – https://github.com/ryansb/cfn-wrapper-python ● Expose Custom::YourThing interface to templates ● Anything boto3 supports, you can add to CloudFormation

  21. Q u e s t i o n T i m e !

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend