Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting started with AWS Cloudformation using P...

Getting started with AWS Cloudformation using Python

An introduction to AWS Cloudformation using Python. It talks about using the troposphere Python library to create AWS Cloudformation templates

Omidiora Samuel

September 16, 2017
Tweet

Other Decks in Programming

Transcript

  1. Getting started with AWS Cloudformation using Python PyCon NG 2017

    OMIDIORA Samuel DevOps Engineer @ TerragonGroup
  2. Agenda • What is AWS Cloudformation? • Anatomy of a

    Cloudformation template • What is Troposphere? • Simple Template using Troposphere python library • Quick AWS Walkthrough
  3. What is AWS Cloudformation? gives developers and systems administrators an

    easy way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion https://aws.amazon.com/cloudformation/
  4. - Parameters Parameters section is used to pass values into

    your template when you create a stack. "Parameters" : { "InstanceTypeParameter" : { "Type" : "String", "Default" : "t2.micro", "AllowedValues" : ["t2.micro","m1.small", "m1.large"], "Description" : "Enter t2.micro, m1.small, or m1.large. Default is t2.micro." } } http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html ANATOMY OF A CLOUDFORMATION TEMPLATE
  5. - Mappings Mappings section matches a key to a corresponding

    set of named values. "Mappings" : { "RegionMap" : { "us-east-1" : { "32" : "ami-6411e20d"}, "us-west-1" : { "3a2" : "ami-c9c7978c"}, "eu-west-1" : { "32" : "ami-37c2f643"}, "ap-southeast-1" : { "32" : "ami-66f28c34"}, "ap-northeast-1" : { "32" : "ami-9c03a89d"} } } http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html ANATOMY OF A CLOUDFORMATION TEMPLATE
  6. - Resources Resources section declares the AWS resources that you

    want to include in the stack, such as an Amazon EC2 instance or an Amazon S3 bucket. "Resources" : { "MyEC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "ImageId" : "ami-2f726546" } } } http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html ANATOMY OF A CLOUDFORMATION TEMPLATE
  7. - Outputs Outputs section declares output values that you can

    import into other stacks "Outputs" : { "InstanceID" : { "Description": "The Instance ID", "Value" : { "Ref" : "EC2Instance" } } } http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html ANATOMY OF A CLOUDFORMATION TEMPLATE
  8. - Conditions Conditions section includes statements that is defined when

    a resource is created or when a property is defined. "Conditions" : { "CreateProdResources" : {"Fn::Equals" : [{"Ref" : "EnvType"}, "prod"]} }, http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html ANATOMY OF A CLOUDFORMATION TEMPLATE
  9. What is Troposphere? The troposphere python library allows for easier

    creation of the AWS CloudFormation JSON by writing Python code to describe the AWS resources. Troposphere also includes some basic support for OpenStack resources. https://github.com/cloudtools/troposphere
  10. #1

  11. #2

  12. #3

  13. #4

  14. #5

  15. #6

  16. #7

  17. Wrap-up Using Troposphere makes it easy to • Version Control

    • Make it easy to test our IaC • Don’t mix IaC and manual config Alternatives to AWS Cloudformation • Terraform