Slide 1

Slide 1 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Luis Colon (@luiscolon1) Sr.Developer Advocate, CloudFormation Wed 03.21.2018 Authoring CloudFormation Templates with Cloud9, CodeCommit, Boto3 and Troposphere Meetup: Seattle AWS Architects and Engineers

Slide 2

Slide 2 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. About Me Luis Colon [email protected] ; @luiscolon1 Sr. Dev Advocate, AWS CloudFormation 1.5 years at AWS Previously: Chief Architect / DevOps SDM at TeamQuest Director of R&D, Publishing Company Software Engineering & Data Science, 25+ yrs in tech

Slide 3

Slide 3 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. About You? Active AWS Users? More than 2 years of AWS Experience? CloudFormation Users?

Slide 4

Slide 4 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda CloudFormation 101 About Cloud9 Building a Cloud9 Environment with CloudFormation Editing Files & Running Programs Building CloudFormation templates in Cloud9

Slide 5

Slide 5 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation 101 Over 350,000 customers use AWS CloudFormation Over 75% of the top 10k highest spend AWS customers Over 2.4 million AWS CloudFormation stacks managed Code in YAML or JSON directly or use sample templates Upload local files or from an S3 bucket Create stack using console, API or CLI Stacks and resources are provisioned

Slide 6

Slide 6 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Infrastructure as Code CDN AppServer Database S3 Multi-tier Transactional (Java, LAMP) Cache Containers NoSQL Orchestrate Microservices Transactional (Docker, k8s) Endpoints Step Fn’s IoT Functions Serverless Transactional (Lambda, APIs, IoT) Streams Spark Warehouse ETL Big Data Analytical (Data Lakes, Hubs) …

Slide 7

Slide 7 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Best Practices Consumer website, seller website, mobile backend Search engine, payment gateway, review engine, recommendations CRM database, common monitoring tools, other stateful resources, alarms VPCs, NAT gateways, VPNs, subnets, security groups, load balancers IAM users, groups, roles, policies Frontend Services Backend Services Shared Services Base Network Identity & Access Dev Integ Stage Prod 1 2 Break stacks by layers and lifecycle Reuse stacks by environments

Slide 8

Slide 8 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation 101 About Cloud9 Building a Cloud9 Environment with CloudFormation Editing Files & Running Programs Building CloudFormation templates in Cloud9

Slide 9

Slide 9 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cloud9 IDE • Browser-based • Tablets • Chromebooks • Ace Editor • Previously: Mozilla Bespin / Skywriter

Slide 10

Slide 10 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cloud9 IDE • Syntax highlighting • Live collaboration • Debugging • Command line • EC2 backed

Slide 11

Slide 11 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation 101 About Cloud9 Building a Cloud9 Environment with CloudFormation Editing Files & Running Programs Building CloudFormation templates in Cloud9

Slide 12

Slide 12 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building a Cloud9 Environment with CloudFormation • Start by adding the Cloud9 environment resource • Specify EC2 instance type • Make a CodeCommit repo • Automatically integrated • AWS CLI pre-configured • Python 2 & 3, Node 6 • Prerequisites: • EC2 instance needs a subnet • IAM user must belong to a group with AWSCodeCommitPowerUser and AWSCodeCommitFullAccess policies • Cloud9 is available now in N. Virginia, Ohio, Oregon, Ireland, and Singapore regions

Slide 13

Slide 13 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building a Cloud9 Environment with CloudFormation AWSTemplateFormatVersion: "2010-09-09"
 Description: A CodeCommit Repo and Cloud9 Dev Environment
 Resources:
 MyRepo:
 Type: "AWS::CodeCommit::Repository"
 Properties:
 RepositoryName: MyRepo
 RepositoryDescription: Sample Repo for Cloud9 Demo
 MyC9Environment:
 Type: "AWS::Cloud9::EnvironmentEC2"
 Properties:
 Repositories:
 - PathComponent: /cfn
 RepositoryUrl: !GetAtt MyRepo.CloneUrlHttp
 InstanceType: t2.micro

Slide 14

Slide 14 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo 1

Slide 15

Slide 15 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation 101 About Cloud9 Building a Cloud9 Environment with CloudFormation Editing Files & Running Programs Building CloudFormation templates in Cloud9

Slide 16

Slide 16 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo 2 README.md & sample.py

Slide 17

Slide 17 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation 101 About Cloud9 Building a Cloud9 Environment with CloudFormation Editing Files & Running Programs Building CloudFormation templates in Cloud9

Slide 18

Slide 18 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS SDK • One of the three primary ways to operate in AWS • Boto3 is the Python SDK for AWS • Console, CLI and APIs • Demo: creating S3 buckets with Python and Boto3

Slide 19

Slide 19 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation Authoring • Traditionally: JSON • Most other tools and environments can/still use it • YAML • More human-readable, compact • SDK/API with higher-level language • Python, Ruby, TypeScript, …

Slide 20

Slide 20 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Troposphere • Generate CloudFormation Templates from Python • Mature project on Github • Generate YAML and JSON • Demo: generate a template creating 3 EC2 instances with a for loop in Python

Slide 21

Slide 21 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo 3 AWS SDK, Boto3 and Troposphere

Slide 22

Slide 22 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CloudFormation 101 About Cloud9 Building a Cloud9 Environment with CloudFormation Editing Files & Running Programs Building CloudFormation templates in Cloud9

Slide 23

Slide 23 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Final Thoughts • Cloud9 storage defaults to 8GB • Check blog post at http://amzn.to/2FIzsNs for step by step instructions on how to expand it • Keep your templates versioned • Treat them as code. Really. • Keep them small, reusable, and test them • Validation Pipeline: http://amzn.to/2hrz8rM • see next slide

Slide 24

Slide 24 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 25

Slide 25 text

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thx :) Luis Colon (@luiscolon1 on Twitter & [email protected]) Sr.Developer Advocate, CloudFormation Wed 03.21.2018