Infrastructure IsCode
with the AWSCloud Development Kit
Richard H Boyd
Sr Developer Advocate
AWS DeveloperTools
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
• Our infrastructure management journey
• The AWS Cloud Development Kit (AWS CDK)
• Demo: Build an AWS CDK app
• A lot more to explore
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Manual
� Easy to get started
� Not reproducible
� Error prone
� Time consuming Manual
High
level
Low level
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Scripted
� What happens if an API call fails?
� How do I make updates?
� How do I know a resource is ready?
� How do I roll back?
Scripted
Manual
High
level
Low level
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Resourceprovisioning engines
AWS CloudFormation
template
(JSON/YAML)
HashiCorp Configuration
Language (HCL)
Desired state configuration
Declarative
Scripted
Manual
High
level
Low level
� Easy to automate
� Reproducible
� Configuration syntax
� No abstraction, lots of details
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DocumentObject Models (DOMs)
Troposphere Python
SparkleFormation Ruby
GoFormation Go
…
if statements, for loops, IDE benefits
Ex: 218 lines ofTroposphere for aVPC
AWS
CloudFormation
Template
� Familiar code ♥️
� Desired state
� Abstraction is not built-in
DOMs
Declarative
Scripted
Manual
High
level
Low level
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS
CloudFormation
template
AWS CDK application
Stack(s)
Construct Construct
AWS CDK
Componentized
DOMs
Declarative
Scripted
Manual
High
level
Low
level
Resources
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Construct
Library
AWSCDK
Componentized
DOMs
Declarative
Scripted
Manual
High
level
Low level
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Componentized
DOMs
Declarative
Scripted
Manual
High
level
Low level
AWSCDK
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo –Goals
• CDK concepts
• CDK CLI workflow
• AWS construct library HelloCdkStack
event source
SQS Queue
NewTweets
CloudWatch
Logs
console.log
send-message
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
GettingStarted
npm install -g aws-cdk
cdk init --language <typescript | java | csharp | ...>
CloudFormation
Template
“compiler”
CDK CLI
“processor”
“assembly
language”
“source”
synthesize deployexecutes
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Constructs
• Thinking in constructs
• Permissions – Grant APIs
• Wiring runtime configuration
HelloCdkStack
SQS Queue
NewTweets
QueueRecorder
put-item
inputQueuesend-message
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
HelloCdkStack
Tweet queue
Input Queue
put-item
SQS queue
new tweets
Amazon
Cloudwatch
scheduled event
polling schedule
DynamoDB
checkpoints table
trigger
update
checkpoint
send message
search?q=TEXT
Queue recorder
Sample Application
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS constructlibrary
• Amazon Elastic Container Service
(Amazon ECS)
• AWS Lambda
• Amazon API Gateway
• Amazon Elastic Cloud Compute
(Amazon EC2)
• VPCs, security groups, Auto Scaling
• Amazon CloudWatch
• Metrics, alarms, dashboards
• AWS Step Functions
• AWS CodePipeline
• AWS Auto Scaling
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Multi-language support
Coming soon!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Advanced topics
• Multi-stack and cross-region applications
• Declarative constructs with AWS CDK applets
• Working with the AWS CloudFormation DOM
• Embedding existing AWS CloudFormation templates
• Importing resources from other stacks
• Embedding code bundles, docker files, and others into constructs
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Nextsteps
• Try out the CDK
• https://cdkworkshop.com
• https://awslabs.github.io/aws-cdk
• https://github.com/awslabs/cdk-reinvent
• Engage with us
• https://github.com/awslabs/aws-cdk
• https://gitter.im/awslabs/aws-cdk
• Check out related sessions
Thank you!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Richard H Boyd
@rchrdbyd

Infrastructure is code with the AWS cloud development kit

  • 1.
    Infrastructure IsCode with theAWSCloud Development Kit Richard H Boyd Sr Developer Advocate AWS DeveloperTools
  • 2.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Agenda • Our infrastructure management journey • The AWS Cloud Development Kit (AWS CDK) • Demo: Build an AWS CDK app • A lot more to explore
  • 3.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 4.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Manual � Easy to get started � Not reproducible � Error prone � Time consuming Manual High level Low level
  • 5.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Scripted � What happens if an API call fails? � How do I make updates? � How do I know a resource is ready? � How do I roll back? Scripted Manual High level Low level
  • 6.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Resourceprovisioning engines AWS CloudFormation template (JSON/YAML) HashiCorp Configuration Language (HCL) Desired state configuration Declarative Scripted Manual High level Low level � Easy to automate � Reproducible � Configuration syntax � No abstraction, lots of details
  • 7.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. DocumentObject Models (DOMs) Troposphere Python SparkleFormation Ruby GoFormation Go … if statements, for loops, IDE benefits Ex: 218 lines ofTroposphere for aVPC AWS CloudFormation Template � Familiar code ♥️ � Desired state � Abstraction is not built-in DOMs Declarative Scripted Manual High level Low level
  • 8.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 9.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS CloudFormation template AWS CDK application Stack(s) Construct Construct AWS CDK Componentized DOMs Declarative Scripted Manual High level Low level Resources
  • 10.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS Construct Library AWSCDK Componentized DOMs Declarative Scripted Manual High level Low level
  • 11.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Componentized DOMs Declarative Scripted Manual High level Low level AWSCDK
  • 12.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Demo –Goals • CDK concepts • CDK CLI workflow • AWS construct library HelloCdkStack event source SQS Queue NewTweets CloudWatch Logs console.log send-message
  • 13.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. GettingStarted npm install -g aws-cdk cdk init --language <typescript | java | csharp | ...> CloudFormation Template “compiler” CDK CLI “processor” “assembly language” “source” synthesize deployexecutes
  • 14.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Constructs • Thinking in constructs • Permissions – Grant APIs • Wiring runtime configuration HelloCdkStack SQS Queue NewTweets QueueRecorder put-item inputQueuesend-message
  • 15.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. HelloCdkStack Tweet queue Input Queue put-item SQS queue new tweets Amazon Cloudwatch scheduled event polling schedule DynamoDB checkpoints table trigger update checkpoint send message search?q=TEXT Queue recorder Sample Application
  • 16.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 17.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS constructlibrary • Amazon Elastic Container Service (Amazon ECS) • AWS Lambda • Amazon API Gateway • Amazon Elastic Cloud Compute (Amazon EC2) • VPCs, security groups, Auto Scaling • Amazon CloudWatch • Metrics, alarms, dashboards • AWS Step Functions • AWS CodePipeline • AWS Auto Scaling
  • 18.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Multi-language support Coming soon!
  • 19.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Advanced topics • Multi-stack and cross-region applications • Declarative constructs with AWS CDK applets • Working with the AWS CloudFormation DOM • Embedding existing AWS CloudFormation templates • Importing resources from other stacks • Embedding code bundles, docker files, and others into constructs
  • 20.
    © 2020, AmazonWeb Services, Inc. or its affiliates. All rights reserved. Nextsteps • Try out the CDK • https://cdkworkshop.com • https://awslabs.github.io/aws-cdk • https://github.com/awslabs/cdk-reinvent • Engage with us • https://github.com/awslabs/aws-cdk • https://gitter.im/awslabs/aws-cdk • Check out related sessions
  • 21.
    Thank you! © 2020,Amazon Web Services, Inc. or its affiliates. All rights reserved. Richard H Boyd @rchrdbyd