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

AWS CDK - Infrastructure as Code

AWS CDK - Infrastructure as Code

Slides for my AWS CDK talk at DevOps Meetup Karlsruhe, Germany

Alexander Zeitler

February 19, 2020
Tweet

More Decks by Alexander Zeitler

Other Decks in Programming

Transcript

  1. Level 0: Manual Infrastructure Setup 5 AWS CDK Error prone

    Not reproducable Time consuming Easy to get started Learn new Services
  2. Level 1: Imperative Infrastructure as Code 7 AWS CDK Error

    Handling (Retry) Infrastructure Updates Readiness Checks Rollback Concurrency
  3. Level 1: Imperative Infrastructure as Code 8 AWS CDK Boilerplate

    Coding Time consuming More mature than Manual • Faster • Reproducable (from Scratch)
  4. Level 2: Declarative Infrastructure as Code 11 AWS CDK AWS

    CloudFormation Template HashiCorp Configuration Language Desired State Configuration AWS CloudFormation
  5. Level 2: Declarative Infrastructure as Code 12 AWS CDK Syntax

    Lack of Abstractions Chatty Automation Reproducable Handles create vs. update
  6. Level 3: AWS Cloud Development Kit (CDK) 16 AWS CDK

    stack.ts AWS CFN AWS SDK AWS CDK
  7. AWS CDK Constructs • Low-Level constructs based on AWS CloudFormation

    • IAM Policy, IAM User, IAM Group, IAM Permission… • S3 Bucket • Route53 HostedZone • AWS Lambda • CloudWatch 17 AWS CDK
  8. AWS CDK Stacks 18 AWS CDK Stack(s) Construct Construct AWS

    CloudFormation CloudFormation Template
  9. AWS CDK 21 AWS CDK Write Code in familiar language

    Create dependent resources with a single line of code Still declarative (CFN), handles create vs. update
  10. AWS CDK - Commands 22 AWS CDK • cdk init

    • cdk bootstrap • cdk synth • cdk deploy • cdk destroy
  11. CDK Components / Patterns • Opinionated Compositions of CDK Constructs

    • Permissions to deploy a PWA on S3 with route53 CNAME • Add/Remove CNAME in HostedZone • route53:ChangeResourceRecordSets • route53:ListHostedZonesByName • route53:GetHostedZone • route53:GetChange • Create S3 Bucket / Deploy to S3 Bucket 25 AWS CDK
  12. 26 AWS CDK IAM Base (Administrators etc.) AWS root Account

    CDK Application / Service CDK Construct Security CI/CD CDK Pattern CDK Construct AWS CDK – Patterns
  13. CDK Components / Patterns • Separation of Concerns • Reusable

    across teams / services / applications • “Best practices as Code” (Patterns) • Least privilege • Tested 27 AWS CDK
  14. Resources Links • CDK Workshop: https://cdkworkshop.com/ • PDMLab CDK Constructs:

    https://www.npmjs.com/package/@pdmlab/cdk-constructs • CDK Patterns: https://cdkpatterns.com/ • Building Cross-platform CDK Constructs: https://www.matthewbonig.com/2020/01/11/creating-constructs/ • CDK constructs on npm: #cdk • CDK Catalog on Twitter: @awscdkio 29 AWS CDK