SlideShare a Scribd company logo
© 2020, Amazon Web Services, Inc. or its Affiliates.
Infrastructure as Code with
AWS Cloud Development Kit
Rohini Gaonkar
Sr. Developer Advocate, AWS
@rohini_gaonkar
@rohini-gaonkar-1503
27th June 2020
© 2020, Amazon Web Services, Inc. or its Affiliates.
Infrastructure is Code with AWS
Cloud Development Kit
Rohini Gaonkar
Sr. Developer Advocate, AWS
@rohini_gaonkar
@rohini-gaonkar-1503
27th June 2020
© 2020, Amazon Web Services, Inc. or its Affiliates.
Hello World..!
 Born in Cloud!
 With AWS for 6+ years
 Started as Cloud Support Engineer, Cape Town, South Africa
 Worked as AWS Solutions Architect in Singapore and in Mumbai, India
 Now a Developer Advocate, India.
@rohini_gaonkar
@rohini-gaonkar-1503
© 2020, Amazon Web Services, Inc. or its Affiliates.
Agenda
• AWS Cloud Development Kit (CDK)
• Why,
• What, and
• How with a demo
• A Glimpse into CDK8s, with a Demo
• Learn & Contribute
© 2020, Amazon Web Services, Inc. or its Affiliates.
Evolution of Infrastructure
Provisioning in Cloud
© 2020, Amazon Web Services, Inc. or its Affiliates.
Level 0: Creating infrastructure by hand
Your
organization’s
infrastructure
© 2020, Amazon Web Services, Inc. or its Affiliates.
High level
Low level
DOMs
Declarative
Scripted
Manual
Componentized
Level 0: Creating infrastructure by hand
� Easy to get started
☹Not reproducible, similar infrastructure for different
environments must be recreated everytime
☹Time consuming to follow click through Console
© 2020, Amazon Web Services, Inc. or its Affiliates.
Level 1: Imperative infrastructure as code
Your
organization’s
infrastructure
deploy.script
AWS SDK
© 2020, Amazon Web Services, Inc. or its Affiliates.
High level
Low level
DOMs
Declarative
Scripted
Manual
Componentized
Level 1: Imperative infrastructure as code
resource = getResource(xyz)
if (resource == desiredResource) {
return
} else if (!resource) {
createResource(desiredResource)
} else {
updateResource(desiredResource)
}deploy.script
☹Lots of boilerplate
☹What if something fails and we
need to retry?
☹What if two people try to run
the script at once?
☹Race conditions?
☹Configuration drift?
aws s3api create-bucket --bucket my-bucket --region us-east-1
© 2020, Amazon Web Services, Inc. or its Affiliates.
Level 2: Declarative infrastructure as code
Your
organization’s
infrastructure
infrastructure.txt
AWS
CloudFormation
HashiCorp
Terraform
AWS SDK
© 2020, Amazon Web Services, Inc. or its Affiliates.
Declarative
High level
Low level
DOMs
Scripted
Manual
Componentized
Level 2: Declarative infrastructure as code
infrastructure.txt
Just a list of each resource to create and its
properties, in this caseYAML format
Some minor helper functions may be built in to
aid in fetching values dynamically
Resources:
# VPC in which containers will be networked.
# It has two public subnets
# We distribute the subnets across the first two available subnets
# for the region, for high availability.
VPC:
Type: AWS::EC2::VPC
Properties:
EnableDnsSupport: true
EnableDnsHostnames: true
CidrBlock: !FindInMap ['SubnetConfig', 'VPC', 'CIDR']
# Two public subnets, where containers can have public IP addresses
PublicSubnetOne:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: {Ref: 'AWS::Region'}
VpcId: !Ref 'VPC'
CidrBlock: !FindInMap ['SubnetConfig', 'PublicOne', 'CIDR']
MapPublicIpOnLaunch: true
PublicSubnetTwo:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: {Ref: 'AWS::Region'}
VpcId: !Ref 'VPC'
CidrBlock: !FindInMap ['SubnetConfig', 'PublicTwo', 'CIDR']
MapPublicIpOnLaunch: true
� Easy to automate
� Reproducible
� Configuration syntax
☹ No abstraction, lots of details
© 2020, Amazon Web Services, Inc. or its Affiliates.
Level 3: Document Object Models (DOMs)
Your
organization’s
infrastructure
app.py
AWS
CloudFormation
AWS SDK
Troposphere Python
SparkleFormation Ruby
GoFormation Go
…
app.template
© 2020, Amazon Web Services, Inc. or its Affiliates.
Manual
High level
Low level
DOMs
Declarative
Scripted
Componentized
Level 3: Document Object Models (DOMs)
app.py
� Write in a familiar programming language
� Real Code - Can use if statements, for
loops, IDE benefits
☹Abstraction is not built-in –
Ex: 218 lines ofTroposphere for aVPC
© 2020, Amazon Web Services, Inc. or its Affiliates.
Level 4: AWS Cloud Development Kit (AWS CDK)
Your
organization’s
infrastructure
app.js
AWS
CloudFormation
AWS SDKAWS CDK
© 2020, Amazon Web Services, Inc. or its Affiliates.
High level
Low level
DOMs
Declarative
Scripted
Manual
Componentized
Level 4: AWS CDK
� Each stack is made up of
“constructs,” which are simple
classes in the code
� Still declarative, no need to handle
create vs update
app.js
app.py
class MyService extends cdk.Stack {
constructor(scope: cdk.App, id: string) {
super(scope, id);
// Network for all the resources
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 });
// Cluster to hold all the containers
const cluster = new ecs.Cluster(this, 'Cluster', { vpc: vpc });
// Load balancer for the service
const LB = new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc: vpc,
internetFacing: true
});
}
}
� Write in a familiar programming language
� Create many underlying AWS resources at
once with a single construct
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Cloud Development Kit
(AWS CDK)
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK Announcement History
AUG 2018
CDK developer
preview
APRIL 2020NOV 2019
GA
Java and C#
JUL 2019
CDK GA
TypeScript
and Python
Public
Roadmap
MAY 2020
CDK8s Alpha
Typescript
and Python
???
+1
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS
CloudFormation
template
AWS CDK Application
Stack(s)
Construct Construct
AWS CDK – ConstructTree
Resources
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CDK
The big picture—from AWS CDK application to provisioned infrastructure
Framework CLI
CDK Application
Stack(s)
ConstructConstruct
“Source” “Compiler” “Assembly language” “Processor”
Execute Synthesize Deploy
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CDK
AWS Construct Library
Framework CLI
CDK Application
Stack(s)
ConstructConstruct
Core framework AWS CDK CLI
Serverless
Containers CI/ CD
Application Integration / Foundational
Autoscaling
Main components
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Construct Library (L2 constructs)
• AWS Lambda
• Amazon API Gateway
• AWS DynamoDB
• AWS Step Functions
• Amazon CloudWatch
• Metrics, alarms, dashboards
• AWS CodePipeline
• AWS Auto Scaling
• Amazon Elastic Cloud Compute (Amazon EC2)
• VPCs, security groups, Auto Scaling
• ……
https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html
Includes a module for each AWS service that offer rich API
The aim is to reduce the complexity and glue logic required when integrating
variousAWS services to achieve your goals on AWS.
© 2020, Amazon Web Services, Inc. or its Affiliates.
CLIWorkflow
cdk bootstrap – Deploys the CDK toolkit stack into anAWS environment
cdk init – Creates a new CDK project
Add construct(s)
e.g.,npm install @aws-cdk/aws-lambda  TERMINAL
import * as ec2 from '@aws-cdk/aws-ec2’;  TYPESCRIPT CODE
Compile your code if needed
e.g., npm run build OR npm run watch
cdk synth – Synthesizes and prints the AWS CloudFormation template for the stack
cdk deploy – Deploys the stack(s) into your AWS account
cdk destroy – Destroys the stack(s)
cdk diff - Compares the specified stack with the deployed stack or a local template file
© 2020, Amazon Web Services, Inc. or its Affiliates.
cdk init
$ cdk init
Available templates:
* app:Template for a CDK Application
└─ cdk init app --language=[csharp|fsharp|java|javascript|python|typescript]
* lib:Template for a CDK Construct Library
└─ cdk init lib --language=typescript
* sample-app: Example CDK Application with some constructs
└─ cdk init sample-app --language=[csharp|fsharp|java|javascript|python|typescript]
© 2020, Amazon Web Services, Inc. or its Affiliates.
Workflow
cdk bootstrap – Deploys the CDK toolkit stack into anAWS environment
cdk init – Creates a new CDK project
Add construct(s)
e.g.,npm install @aws-cdk/aws-lambda  TERMINAL
import * as ec2 from '@aws-cdk/aws-ec2’;  TYPESCRIPT CODE
Compile your code if needed
e.g., npm run build OR npm run watch
cdk synth – Synthesizes and prints the AWS CloudFormation template for the stack
cdk deploy – Deploys the stack(s) into your AWS account
cdk destroy – Destroys the stack(s)
cdk diff - Compares the specified stack with the deployed stack or a local template file
© 2020, Amazon Web Services, Inc. or its Affiliates.
Dive Deep into Constructs
© 2020, Amazon Web Services, Inc. or its Affiliates.
Types of Constructs – Low Level
• Represent all of the AWS resources that are available in AWS CloudFormation.
• Named CfnXyz, where Xyz represents the name of the resource.
• You must explicitly configure all required resource properties
E.g. ec2.CfnVPC represents the AWS::EC2::VPC CFN Resource.
cidrBlock is a required property
Define Subnets & other resources separately
cdk synth
© 2020, Amazon Web Services, Inc. or its Affiliates.
Types of Constructs – High Level
• High level intent-based API.
• Handle much of the details for resources, boilerplate, and glue logic required by
CFN constructs.
• Offer convenient defaults and reduce the need to know all the details about the
AWS resources.
E.g. ec2.Vpc represents anVPC with
additional properties, resources, methods.
456 lines of JSON
CloudFormation template
© 2020, Amazon Web Services, Inc. or its Affiliates.
Types of Constructs – Patterns
• Patterns are designed to help you complete common tasks in AWS
• Common architecture patterns built on top of the basic patterns, often involving
multiple kinds of resources.
E.g., the aws-ecs-patterns.ApplicationLoadBalancedFargateService
construct represents an architecture that includes an AWS Fargate container cluster
employing an Application Load Balancer (ALB).
829 lines of JSON
CloudFormation template
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Solutions Constructs - Patterns
Can easily be assembled into production-ready well-architected applications
• Pre-built
• Multi-service architecture
• Vetted
• Configurable
© 2020, Amazon Web Services, Inc. or its Affiliates.
Constructs Release Levels
• Stable release, safe to use!
• Experimental release, we are still working on this!
E.g. :
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK Demo
https://github.com/rohinigaonkar/my_microservices_app
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CDK
The big picture—from AWS CDK application to provisioned infrastructure
Framework CLI
CDK Application
Stack(s)
ConstructConstruct
“Source” “Compiler” “Assembly language” “Processor”
Execute Synthesize Deploy
© 2020, Amazon Web Services, Inc. or its Affiliates.
One CDK construct expands to many underlying resources
270 lines ofYAML
OR
456 lines of JSON
CloudFormation template
I don’t have to write!
// Network for all the resources
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 });
cdk synth
© 2020, Amazon Web Services, Inc. or its Affiliates.
VPC
Public Subnet in
Availability Zone
Public Subnet in
Availability Zone 2
Private Subnet in
Availability Zone
Private Subnet in
Availability Zone 2
Internet
gateway
NAT gateway NAT gateway
One CDK construct expands to many underlying resources
cdk deploy
// Network for all the resources
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 });
AWS Cloud
Route table
RouteTable RouteTable
EIP EIP
© 2020, Amazon Web Services, Inc. or its Affiliates.
To Summarize…
• Re-use : Define high level abstractions, share them, and publish them to your
team, company, or community
• Real- code : Code completion within your IDE
• Organize your project into logical modules
• Use object-oriented techniques to create a model of your system
• Use logic (if statements, for-loops, etc) when defining your infrastructure
• Testing your infrastructure code using industry-standard protocols
• Use your existing code review workflow
© 2020, Amazon Web Services, Inc. or its Affiliates.
Another Open Source Project - JSII
Open source framework to define cloud infrastructure in popular programming
languages
‘By compiling our source module using jsii, we can now package it as modules in one of the supported target
languages.’
JSII (JavaScript Interoperability Interface)
https://github.com/aws/jsii
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK8s – CDK for Kubernetes
https://github.com/rohinigaonkar/kubHello
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK8s – CDK for Kubernetes
• Define Kubernetes native apps and abstractions
• This is day one. cdk8s is alpha today and we have big things planned!
• Supported languages are Python, Typescript, and Javascript.
• Support for more languages (including Go, Java, and .NET) is on our roadmap!
• Roadmap published on Github.
https://github.com/awslabs/cdk8s
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK8s – CDK for Kubernetes
• cdk8s is built for the entire community.
• Agnostic - It can work with any cluster, anywhere.
• We love contributions. Open a issue or pull request at
github.com/awslabs/cdk8s
© 2020, Amazon Web Services, Inc. or its Affiliates.
Kubernetes
Manifest FileAWS CDK8s Application
Chart(s)
Construct Construct
AWS CDK8s – ConstructTree
Kubernetes
Resources
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK8s Demo
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS CDK8s
The big picture—from AWS CDK8s application to provisioned Kubernetes applications
“Source” “Compiler” “Assembly language” “Processor”
Kubernetes
Manifest File
Execute Synthesize Deploy
AWS CDK8s Application
Chart(s)
Construct Construct
© 2020, Amazon Web Services, Inc. or its Affiliates.
CDK8s to Kubernetes Manifest file
cdk8s
synth
© 2020, Amazon Web Services, Inc. or its Affiliates.
To summarize..
• Imperative approach to declarative state
• Works for any cluster - it is environment agnostic.
• Use any Kubernetes API version and custom resources
• Open Source – Built for entire Kubernetes community, not just AWS customers
• Language support – plans to add support for more languages
© 2020, Amazon Web Services, Inc. or its Affiliates.
Contribute
https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md
© 2020, Amazon Web Services, Inc. or its Affiliates.
Next steps
Engage
• github.com/aws/aws-cdk
• gitter.im/awslabs/aws-cdk
Get started
• cdkworkshop.com
• aws.amazon.com/cdk
• aws.amazon.com/vscode
© 2020, Amazon Web Services, Inc. or its Affiliates.
awesome-cdk
• Open CDK Guide opinionated set of tips and best practices
• kevinslin/open-cdk
• punchcard type-safe AWS infrastructure
• punchcard/punchcard
• aws-cdk-pure purely functional CDK
• fogfish/aws-cdk-pure
• cdk-clj a clojure wrapper for the CDK
• StediInc/cdk-clj
• cdk-components a collection of higher-level cdk constructs
• cloudcomponents/cdk-components
• CDK GitHub Action
• ScottBrenner/aws-cdk-action
eladb/awesome-cdk
DISCLAIMER: this is a personal project and not affiliated with Amazon or AWS.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Go Build..!
Rohini Gaonkar
Sr. Developer Advocate, AWS
@rohini_gaonkar
@rohini-gaonkar-1503

More Related Content

Recently uploaded

Things to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUUThings to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUU
FODUU
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
CAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on BlockchainCAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on Blockchain
Claudio Di Ciccio
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 

Recently uploaded (20)

Things to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUUThings to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUU
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
CAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on BlockchainCAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on Blockchain
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Infrastructure as Code with AWS Cloud Development Kit (CDK)

  • 1. © 2020, Amazon Web Services, Inc. or its Affiliates. Infrastructure as Code with AWS Cloud Development Kit Rohini Gaonkar Sr. Developer Advocate, AWS @rohini_gaonkar @rohini-gaonkar-1503 27th June 2020
  • 2. © 2020, Amazon Web Services, Inc. or its Affiliates. Infrastructure is Code with AWS Cloud Development Kit Rohini Gaonkar Sr. Developer Advocate, AWS @rohini_gaonkar @rohini-gaonkar-1503 27th June 2020
  • 3. © 2020, Amazon Web Services, Inc. or its Affiliates. Hello World..!  Born in Cloud!  With AWS for 6+ years  Started as Cloud Support Engineer, Cape Town, South Africa  Worked as AWS Solutions Architect in Singapore and in Mumbai, India  Now a Developer Advocate, India. @rohini_gaonkar @rohini-gaonkar-1503
  • 4. © 2020, Amazon Web Services, Inc. or its Affiliates. Agenda • AWS Cloud Development Kit (CDK) • Why, • What, and • How with a demo • A Glimpse into CDK8s, with a Demo • Learn & Contribute
  • 5. © 2020, Amazon Web Services, Inc. or its Affiliates. Evolution of Infrastructure Provisioning in Cloud
  • 6. © 2020, Amazon Web Services, Inc. or its Affiliates. Level 0: Creating infrastructure by hand Your organization’s infrastructure
  • 7. © 2020, Amazon Web Services, Inc. or its Affiliates. High level Low level DOMs Declarative Scripted Manual Componentized Level 0: Creating infrastructure by hand � Easy to get started ☹Not reproducible, similar infrastructure for different environments must be recreated everytime ☹Time consuming to follow click through Console
  • 8. © 2020, Amazon Web Services, Inc. or its Affiliates. Level 1: Imperative infrastructure as code Your organization’s infrastructure deploy.script AWS SDK
  • 9. © 2020, Amazon Web Services, Inc. or its Affiliates. High level Low level DOMs Declarative Scripted Manual Componentized Level 1: Imperative infrastructure as code resource = getResource(xyz) if (resource == desiredResource) { return } else if (!resource) { createResource(desiredResource) } else { updateResource(desiredResource) }deploy.script ☹Lots of boilerplate ☹What if something fails and we need to retry? ☹What if two people try to run the script at once? ☹Race conditions? ☹Configuration drift? aws s3api create-bucket --bucket my-bucket --region us-east-1
  • 10. © 2020, Amazon Web Services, Inc. or its Affiliates. Level 2: Declarative infrastructure as code Your organization’s infrastructure infrastructure.txt AWS CloudFormation HashiCorp Terraform AWS SDK
  • 11. © 2020, Amazon Web Services, Inc. or its Affiliates. Declarative High level Low level DOMs Scripted Manual Componentized Level 2: Declarative infrastructure as code infrastructure.txt Just a list of each resource to create and its properties, in this caseYAML format Some minor helper functions may be built in to aid in fetching values dynamically Resources: # VPC in which containers will be networked. # It has two public subnets # We distribute the subnets across the first two available subnets # for the region, for high availability. VPC: Type: AWS::EC2::VPC Properties: EnableDnsSupport: true EnableDnsHostnames: true CidrBlock: !FindInMap ['SubnetConfig', 'VPC', 'CIDR'] # Two public subnets, where containers can have public IP addresses PublicSubnetOne: Type: AWS::EC2::Subnet Properties: AvailabilityZone: Fn::Select: - 0 - Fn::GetAZs: {Ref: 'AWS::Region'} VpcId: !Ref 'VPC' CidrBlock: !FindInMap ['SubnetConfig', 'PublicOne', 'CIDR'] MapPublicIpOnLaunch: true PublicSubnetTwo: Type: AWS::EC2::Subnet Properties: AvailabilityZone: Fn::Select: - 1 - Fn::GetAZs: {Ref: 'AWS::Region'} VpcId: !Ref 'VPC' CidrBlock: !FindInMap ['SubnetConfig', 'PublicTwo', 'CIDR'] MapPublicIpOnLaunch: true � Easy to automate � Reproducible � Configuration syntax ☹ No abstraction, lots of details
  • 12. © 2020, Amazon Web Services, Inc. or its Affiliates. Level 3: Document Object Models (DOMs) Your organization’s infrastructure app.py AWS CloudFormation AWS SDK Troposphere Python SparkleFormation Ruby GoFormation Go … app.template
  • 13. © 2020, Amazon Web Services, Inc. or its Affiliates. Manual High level Low level DOMs Declarative Scripted Componentized Level 3: Document Object Models (DOMs) app.py � Write in a familiar programming language � Real Code - Can use if statements, for loops, IDE benefits ☹Abstraction is not built-in – Ex: 218 lines ofTroposphere for aVPC
  • 14. © 2020, Amazon Web Services, Inc. or its Affiliates. Level 4: AWS Cloud Development Kit (AWS CDK) Your organization’s infrastructure app.js AWS CloudFormation AWS SDKAWS CDK
  • 15. © 2020, Amazon Web Services, Inc. or its Affiliates. High level Low level DOMs Declarative Scripted Manual Componentized Level 4: AWS CDK � Each stack is made up of “constructs,” which are simple classes in the code � Still declarative, no need to handle create vs update app.js app.py class MyService extends cdk.Stack { constructor(scope: cdk.App, id: string) { super(scope, id); // Network for all the resources const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 }); // Cluster to hold all the containers const cluster = new ecs.Cluster(this, 'Cluster', { vpc: vpc }); // Load balancer for the service const LB = new elbv2.ApplicationLoadBalancer(this, 'LB', { vpc: vpc, internetFacing: true }); } } � Write in a familiar programming language � Create many underlying AWS resources at once with a single construct
  • 16. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS Cloud Development Kit (AWS CDK)
  • 17. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK Announcement History AUG 2018 CDK developer preview APRIL 2020NOV 2019 GA Java and C# JUL 2019 CDK GA TypeScript and Python Public Roadmap MAY 2020 CDK8s Alpha Typescript and Python ??? +1
  • 18. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CloudFormation template AWS CDK Application Stack(s) Construct Construct AWS CDK – ConstructTree Resources
  • 19. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CDK The big picture—from AWS CDK application to provisioned infrastructure Framework CLI CDK Application Stack(s) ConstructConstruct “Source” “Compiler” “Assembly language” “Processor” Execute Synthesize Deploy
  • 20. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CDK AWS Construct Library Framework CLI CDK Application Stack(s) ConstructConstruct Core framework AWS CDK CLI Serverless Containers CI/ CD Application Integration / Foundational Autoscaling Main components
  • 21. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS Construct Library (L2 constructs) • AWS Lambda • Amazon API Gateway • AWS DynamoDB • AWS Step Functions • Amazon CloudWatch • Metrics, alarms, dashboards • AWS CodePipeline • AWS Auto Scaling • Amazon Elastic Cloud Compute (Amazon EC2) • VPCs, security groups, Auto Scaling • …… https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html Includes a module for each AWS service that offer rich API The aim is to reduce the complexity and glue logic required when integrating variousAWS services to achieve your goals on AWS.
  • 22. © 2020, Amazon Web Services, Inc. or its Affiliates. CLIWorkflow cdk bootstrap – Deploys the CDK toolkit stack into anAWS environment cdk init – Creates a new CDK project Add construct(s) e.g.,npm install @aws-cdk/aws-lambda  TERMINAL import * as ec2 from '@aws-cdk/aws-ec2’;  TYPESCRIPT CODE Compile your code if needed e.g., npm run build OR npm run watch cdk synth – Synthesizes and prints the AWS CloudFormation template for the stack cdk deploy – Deploys the stack(s) into your AWS account cdk destroy – Destroys the stack(s) cdk diff - Compares the specified stack with the deployed stack or a local template file
  • 23. © 2020, Amazon Web Services, Inc. or its Affiliates. cdk init $ cdk init Available templates: * app:Template for a CDK Application └─ cdk init app --language=[csharp|fsharp|java|javascript|python|typescript] * lib:Template for a CDK Construct Library └─ cdk init lib --language=typescript * sample-app: Example CDK Application with some constructs └─ cdk init sample-app --language=[csharp|fsharp|java|javascript|python|typescript]
  • 24. © 2020, Amazon Web Services, Inc. or its Affiliates. Workflow cdk bootstrap – Deploys the CDK toolkit stack into anAWS environment cdk init – Creates a new CDK project Add construct(s) e.g.,npm install @aws-cdk/aws-lambda  TERMINAL import * as ec2 from '@aws-cdk/aws-ec2’;  TYPESCRIPT CODE Compile your code if needed e.g., npm run build OR npm run watch cdk synth – Synthesizes and prints the AWS CloudFormation template for the stack cdk deploy – Deploys the stack(s) into your AWS account cdk destroy – Destroys the stack(s) cdk diff - Compares the specified stack with the deployed stack or a local template file
  • 25. © 2020, Amazon Web Services, Inc. or its Affiliates. Dive Deep into Constructs
  • 26. © 2020, Amazon Web Services, Inc. or its Affiliates. Types of Constructs – Low Level • Represent all of the AWS resources that are available in AWS CloudFormation. • Named CfnXyz, where Xyz represents the name of the resource. • You must explicitly configure all required resource properties E.g. ec2.CfnVPC represents the AWS::EC2::VPC CFN Resource. cidrBlock is a required property Define Subnets & other resources separately cdk synth
  • 27. © 2020, Amazon Web Services, Inc. or its Affiliates. Types of Constructs – High Level • High level intent-based API. • Handle much of the details for resources, boilerplate, and glue logic required by CFN constructs. • Offer convenient defaults and reduce the need to know all the details about the AWS resources. E.g. ec2.Vpc represents anVPC with additional properties, resources, methods. 456 lines of JSON CloudFormation template
  • 28. © 2020, Amazon Web Services, Inc. or its Affiliates. Types of Constructs – Patterns • Patterns are designed to help you complete common tasks in AWS • Common architecture patterns built on top of the basic patterns, often involving multiple kinds of resources. E.g., the aws-ecs-patterns.ApplicationLoadBalancedFargateService construct represents an architecture that includes an AWS Fargate container cluster employing an Application Load Balancer (ALB). 829 lines of JSON CloudFormation template
  • 29. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS Solutions Constructs - Patterns Can easily be assembled into production-ready well-architected applications • Pre-built • Multi-service architecture • Vetted • Configurable
  • 30. © 2020, Amazon Web Services, Inc. or its Affiliates. Constructs Release Levels • Stable release, safe to use! • Experimental release, we are still working on this! E.g. :
  • 31. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK Demo https://github.com/rohinigaonkar/my_microservices_app
  • 32. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CDK The big picture—from AWS CDK application to provisioned infrastructure Framework CLI CDK Application Stack(s) ConstructConstruct “Source” “Compiler” “Assembly language” “Processor” Execute Synthesize Deploy
  • 33. © 2020, Amazon Web Services, Inc. or its Affiliates. One CDK construct expands to many underlying resources 270 lines ofYAML OR 456 lines of JSON CloudFormation template I don’t have to write! // Network for all the resources const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 }); cdk synth
  • 34. © 2020, Amazon Web Services, Inc. or its Affiliates. VPC Public Subnet in Availability Zone Public Subnet in Availability Zone 2 Private Subnet in Availability Zone Private Subnet in Availability Zone 2 Internet gateway NAT gateway NAT gateway One CDK construct expands to many underlying resources cdk deploy // Network for all the resources const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 }); AWS Cloud Route table RouteTable RouteTable EIP EIP
  • 35. © 2020, Amazon Web Services, Inc. or its Affiliates. To Summarize… • Re-use : Define high level abstractions, share them, and publish them to your team, company, or community • Real- code : Code completion within your IDE • Organize your project into logical modules • Use object-oriented techniques to create a model of your system • Use logic (if statements, for-loops, etc) when defining your infrastructure • Testing your infrastructure code using industry-standard protocols • Use your existing code review workflow
  • 36. © 2020, Amazon Web Services, Inc. or its Affiliates. Another Open Source Project - JSII Open source framework to define cloud infrastructure in popular programming languages ‘By compiling our source module using jsii, we can now package it as modules in one of the supported target languages.’ JSII (JavaScript Interoperability Interface) https://github.com/aws/jsii
  • 37. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK8s – CDK for Kubernetes https://github.com/rohinigaonkar/kubHello
  • 38. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK8s – CDK for Kubernetes • Define Kubernetes native apps and abstractions • This is day one. cdk8s is alpha today and we have big things planned! • Supported languages are Python, Typescript, and Javascript. • Support for more languages (including Go, Java, and .NET) is on our roadmap! • Roadmap published on Github. https://github.com/awslabs/cdk8s
  • 39. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK8s – CDK for Kubernetes • cdk8s is built for the entire community. • Agnostic - It can work with any cluster, anywhere. • We love contributions. Open a issue or pull request at github.com/awslabs/cdk8s
  • 40. © 2020, Amazon Web Services, Inc. or its Affiliates. Kubernetes Manifest FileAWS CDK8s Application Chart(s) Construct Construct AWS CDK8s – ConstructTree Kubernetes Resources
  • 41. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK8s Demo
  • 42. © 2020, Amazon Web Services, Inc. or its Affiliates. AWS CDK8s The big picture—from AWS CDK8s application to provisioned Kubernetes applications “Source” “Compiler” “Assembly language” “Processor” Kubernetes Manifest File Execute Synthesize Deploy AWS CDK8s Application Chart(s) Construct Construct
  • 43. © 2020, Amazon Web Services, Inc. or its Affiliates. CDK8s to Kubernetes Manifest file cdk8s synth
  • 44. © 2020, Amazon Web Services, Inc. or its Affiliates. To summarize.. • Imperative approach to declarative state • Works for any cluster - it is environment agnostic. • Use any Kubernetes API version and custom resources • Open Source – Built for entire Kubernetes community, not just AWS customers • Language support – plans to add support for more languages
  • 45. © 2020, Amazon Web Services, Inc. or its Affiliates. Contribute https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md
  • 46. © 2020, Amazon Web Services, Inc. or its Affiliates. Next steps Engage • github.com/aws/aws-cdk • gitter.im/awslabs/aws-cdk Get started • cdkworkshop.com • aws.amazon.com/cdk • aws.amazon.com/vscode
  • 47. © 2020, Amazon Web Services, Inc. or its Affiliates. awesome-cdk • Open CDK Guide opinionated set of tips and best practices • kevinslin/open-cdk • punchcard type-safe AWS infrastructure • punchcard/punchcard • aws-cdk-pure purely functional CDK • fogfish/aws-cdk-pure • cdk-clj a clojure wrapper for the CDK • StediInc/cdk-clj • cdk-components a collection of higher-level cdk constructs • cloudcomponents/cdk-components • CDK GitHub Action • ScottBrenner/aws-cdk-action eladb/awesome-cdk DISCLAIMER: this is a personal project and not affiliated with Amazon or AWS.
  • 48. © 2020, Amazon Web Services, Inc. or its Affiliates. Go Build..! Rohini Gaonkar Sr. Developer Advocate, AWS @rohini_gaonkar @rohini-gaonkar-1503

Editor's Notes

  1. Easy to get started Not reproducible Error prone Time consuming
  2. The difference between the declarative and the imperative is that the declarative must know the current state, it must know whether the infrastructure already exists to know whether to create it or not. The imperative however has no idea if the infrastructure exists. The imperative example also cannot be easily re-ran, and doesn’t include the ability to update or delete.
  3. 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?
  4. Easy to automate Reproducible Configuration syntax No abstraction, lots of details
  5. But YAML is not a programming language and the usual method of collaboration and sharing of templates is copy-pasting existing templates and adapting those to fit your current needs. This makes the process of describing the infrastructure for a new project or even updating an existing one tedious and very prone to human error. 
  6. Real code ♥️ ️ Desired state Abstraction is not built-in if statements, for loops, IDE benefits
  7. Document Object Models (DOMs) like being behind on CloudFormation-supported services, updates, and some inconsistency in parameter naming.
  8. Real code ♥️ ️ Desired state Abstraction is built-in if statements, for loops, IDE benefits
  9. Picture is analogy between may be python and low level language like C/C++ if you make the switch Infrastructure IS Code Truly IaC, where you can have all the power of programming language of your preference You might have heard this before that 20 lines of CDK code gives you equivalent template of about 1000 lines, that is because the abstraction that CDK provides. If as a developer you are writing yaml templates you still have to know lot of things like best practices, security rules to use. CDK constructs helps to hide those details from you with sensible defaults at the same time if you want you can configure those. Real World problem Conditions (ex: if we add a condition to exclude resources not supported in a specific region, CF would complain about that resource even when the condition to create it was set to false) Reusability: we can create a pool of common constructs and reuse in different project Other thing of condition is, the generated template contains only what the customer needs. We can exclude unused resources before generating the template. All the power of programming language comes with CDK as well And with the pipeline, we can validate code quality, test coverage, security of generated template The speed at which I can develop and iterate using CDK is significantly faster than using AWS CloudFormation alone. 
  10. Developers can use one of the supported programming languages to define reusable cloud components known as Constructs. You compose these together into Stacks and Apps. Use the AWS CDK to define your cloud resources in a familiar programming language. The AWS CDK supports TypeScript, JavaScript, Python, Java, and C#/.Net. Constructs are the basic building blocks of AWS CDK apps. A construct represents a "cloud component" and encapsulates everything AWS CloudFormation needs to create the component. The key pattern for defining higher-level abstractions through constructs is called composition. A high-level construct can be composed from any number of lower-level constructs, and in turn, those could be composed from even lower-level constructs. To enable this pattern, constructs are always defined within the scope of another construct. This scoping pattern results in a hierarchy of constructs known as a construct tree. In the AWS CDK, the root of the tree represents your entire AWS CDK app. Within the app, you typically define one or more stacks, which are the unit of deployment, analogous to AWS CloudFormation stacks. Within stacks, you define resources, or other constructs that eventually contain resources.
  11. CDK you have app and then tree of constructs synthesize template from CDK application AWS Cloudformation is our provisioning engine This is an analogy, just like a compiler compiles your source code into assembly language, CDK compiles your application into Cloudformation template
  12. Core framework: constructs programming model, stacks, apps Construct library: constructs/abstractions for different AWS resources, rich class library for 1st class abstractions CDK CLI: to help us with workflow of development
  13. CDK LIST, CDK DIFF Since TypeScript sources need to be compiled to JavaScript, every time we make a modification to our source files, we would want them to be compiled to .js. This will start the TypeScript compiler (tsc) in “watch” mode, which will monitor your project directory and will automatically compile any changes to your .ts files to .js.
  14. Basic patterns for building Docker images, creating a cluster, task definition, task, or service
  15. Introducing AWS Solutions Constructs Posted On: Jun 22, 2020 We’ve recently added AWS Solutions Constructs to the AWS Solutions Library. AWS Solutions Constructs are pre-built, multi-service architecture patterns that allow customers to quickly assemble well-architected applications using familiar programming tools.  AWS Solutions Constructs, available as a library extension of the AWS Cloud Development Kit, provides customers with over 20 architecture patterns, representing the most commonly used service combinations, such as connecting AWS CloudFront to Amazon S3, or using AWS Lambda to access Amazon S3. All Constructs are vetted by AWS Architects, and reviewed to ensure they follow the principles outlined in the AWS Well-Architected Framework. For example, any Construct that uses S3 has encryption turned on by default to ensure data is encrypted at rest.  AWS Solutions Constructs are listed in the AWS Solutions Library, next to our existing portfolio of 200+ AWS Solutions Implementations (self-deployable reference implementations). To learn more, click here.  
  16. A construct can represent a single resource, such as an Amazon Simple Storage Service (Amazon S3) bucket, or it can represent a higher-level component consisting of multiple AWS CDK resources. Examples of such components include a worker queue with its associated compute capacity, a cron job with monitoring resources and a dashboard, or even an entire app spanning multiple AWS accounts and regions.
  17. CDK you have app and then tree of constructs synthesize template from CDK application AWS Cloudformation is our provisioning engine This is an analogy, just like a compiler compiles your source code into assembly language, CDK compiles your application into Cloudformation template
  18. By default, a VPC will spread over at most 3 Availability Zones available to it. To change the number of Availability Zones that the VPC will spread over, specify the maxAzs property when defining it.
  19. + Smart Product solution provides simple solution of CI/CD pipeline including AWS CodeCommit, AWS CodePipeline, AWS CodeBuild, and AWS Cloud Development Kit.
  20. 20 MINS
  21. Composition of constructs means that you can define reusable components and share them like any other code. For example, a central team can define a construct that implements the company's best practice for a DynamoDB table with backup, global replication, auto-scaling, and monitoring, and share it with teams across a company or publicly. Teams can now use this construct as they would any other library package in their favorite programming language to define their tables and comply with their team's best practices. When the library is updated, developers can pick up the updates and enjoy any bug fixes and improvements through the workflows they already have for their other types of code. Share and reuse your infrastructure as a library
  22. jsii allows code in any language to naturally interact with JavaScript classes. It is the technology that enables the AWS Cloud Development Kit to deliver polyglot libraries from a single codebase! Support for multiple languages is achieved through jsii modules. The magic is really achieved by running a JavaScript runtime and using proxy classes in the target language. this is definitely a key project that is directly connected to CDK’s success.
  23. You can import objects from any Kubernetes API version and custom resource definitions to use with cdk8s. This makes it easy to use cdk8s to easily write entire Kubernetes applications and keep them up to date as applications change.
  24. By default, a VPC will spread over at most 3 Availability Zones available to it. To change the number of Availability Zones that the VPC will spread over, specify the maxAzs property when defining it.
  25. Works for any cluster cdk8s is environment agnostic. It runs locally on your machine and generates standard Kubernetes YAML data, so you can use it with any Kubernetes cluster running anywhere, including on-premises and the cloud Imperative approach to declarative state cdk8s code is written using imperative languages but outputs your desired state as pure Kubernetes YAML. This means you can enjoy the expressiveness and simplicity of imperative programming without compromising on the robustness of the declarative desired state approach. Use any Kubernetes API version and custom resources cdk8s includes a nifty CLI tool that lets you import any version of the Kubernetes API to your project, and update to take advantage of new API versions when you wish. You can also import custom resource definitions. Language support cdk8s lets you define applications using TypeScript, JavaScript, and Python. We plan to add support for more languages, including Go. Open source cdk8s is open source and we welcome community contributions. We built cdk8s for the entire Kubernetes community, not just AWS customers.
  26. A curated list of awesome projects related to the AWS Cloud Development Kit (AWS CDK). DISCLAIMER: this is a personal project and not affiliated with Amazon or AWS.
  27. 25 MINS All high level constructs wrap the low level construct, so at any point it is easy to drop down to low level constructs where you have access to all CloudFormation properties Low level constructs are prefixed with Cfn and there is a direct one to one mapping between all the properties of a low level construct and the resulting CloudFormation. Low level construct: For example, s3.CfnBucket represents the AWS::S3::Bucket CFN Resource. When you use CFN resources, you must explicitly configure all resource properties, which requires a complete understanding of the details of the underlying resource model You can continue to use high level construct but use these methods like addPropertyOverride() offered by low level constructs to configure certain properties not exposed by the high level construct. And if you use low level construct than you need to define all the low lying details and you might not be benefiting from the abstraction offered by the high level constructs https://docs.aws.amazon.com/cdk/latest/guide/constructs.html scope – The construct within which this construct is defined. You should almost always pass this for the scope, because it represents the current scope in which you are defining the construct. id – An identifier that must be unique within this scope. The identifier serves as a namespace for everything that's encapsulated within the scope's subtree and is used to allocate unique identities such as resource names and AWS CloudFormation logical IDs. props – A set of properties or keyword arguments, depending upon the supported language, that define the construct's initial configuration. In most cases, constructs provide sensible defaults, and if all props elements are optional, you can leave out the props parameter completely.
  28. By compiling our source module using jsii, we can now package it as modules in one of the supported target languages. Each target module has the exact same API as the source. This allows users of that target language to use WalterMonitor like any other class:
  29. https://aws.amazon.com/blogs/developer/aws-cdk-developer-preview/ https://aws.amazon.com/blogs/aws/aws-cloud-development-kit-cdk-typescript-and-python-are-now-generally-available/ https://aws.amazon.com/blogs/aws/aws-cloud-development-kit-cdk-java-and-net-are-now-generally-available/ https://aws.amazon.com/blogs/developer/introducing-the-aws-cdk-public-roadmap/ https://aws.amazon.com/blogs/containers/introducing-cdk-for-kubernetes/