Slide 1

Slide 1 text

simalexan Meet Slobodan

Slide 2

Slide 2 text

simalexan

Slide 3

Slide 3 text

simalexan

Slide 4

Slide 4 text

simalexan Build with serverless! Its me!

Slide 5

Slide 5 text

simalexan No server management / ops Scales per use Autofailover Don’t pay 
 for idle

Slide 6

Slide 6 text

simalexan Business is more profitable Faster delivery

Slide 7

Slide 7 text

simalexan Code needs to run on servers! Serverless? That’s not the point! You’re an idiot

Slide 8

Slide 8 text

simalexan It is serverless, 
 the same way WIFI is wireless. Gojko Adzic

Slide 9

Slide 9 text

simalexan

Slide 10

Slide 10 text

simalexan Ok, lets try…

Slide 11

Slide 11 text

simalexan AWS Lambda DynamoDB API Gateway AWS S3 Understanding serverless seems easy

Slide 12

Slide 12 text

simalexan Until you reach AWS CloudFormation Did I miss some space here?! Max 200 resources?? Ack, this is ugly!

Slide 13

Slide 13 text

simalexan You said it was easy, now I have to write ugly YAML… CloudFormation? There’s a better way… I’ve Wasted hours finding the docs…

Slide 14

Slide 14 text

simalexan “Two birds - one stone” Building serverless apps with AWS CDK Aleksandar Simović

Slide 15

Slide 15 text

simalexan Aleksandar Simović • Senior software engineer / Lead serverless engineer
 at ScienceExchange • Coauthor of the “Serverless Applications with Node.js” book • AWS Serverless Hero • AWS SAM / AWS SAM Lambda builders / AWS CDK • Almost 30 serverless apps on 
 AWS Serverless Application Repository • Saved more than $100k at ScienceExchange by implementing several
 serverless solutions.

Slide 16

Slide 16 text

simalexan The “agenda” • Infrastructure Management Journey • AWS CDK • Short Demo • More examples

Slide 17

Slide 17 text

simalexan In the beginning there was a console

Slide 18

Slide 18 text

simalexan Console • Easy to get started • Not reproducible • Error prone • Time Consuming

Slide 19

Slide 19 text

simalexan Scripted Resources
 (pre 2010)

Slide 20

Slide 20 text

simalexan Scripted Resources
 (pre 2010) • What if an API call fails? • How to make updates? • How do you know if a resource is ready? • How to roll back?

Slide 21

Slide 21 text

simalexan Resource Provisioning Engines • AWS CloudFormation • Terraform
 Using declarative configuration • AWS CloudFormation template (JSON/YAML) • HashiCorp Configuration Language (HCL)

Slide 22

Slide 22 text

simalexan

Slide 23

Slide 23 text

simalexan Resource Provisioning Engines • Easy to automate • Reproducible • Good Rollbacks and Updates • Awful syntax • No abstraction, lots of details

Slide 24

Slide 24 text

simalexan Resource Provisioning Engines • Feels like a shopping list / no programming at all • Fair abstractions using Nested Stacks • YAML formatting issues (cfn-lint) • Documentation only online

Slide 25

Slide 25 text

simalexan Document Object Models (DOMs) • Troposphere (Python) • SparkleFormation (Ruby) • GoFormation (Go)

Slide 26

Slide 26 text

simalexan Document Object Models (DOMs) • Real code • Desired state (builds upon CloudFormation) • Abstractions are not built-in

Slide 27

Slide 27 text

simalexan AWS CDK
 (Cloud Development Kit) Software Development Framework 
 Cloud Infrastructure and Applications

Slide 28

Slide 28 text

simalexan

Slide 29

Slide 29 text

simalexan

Slide 30

Slide 30 text

simalexan Componentized • Application = multiple stacks • Stack = multiple constructs • Construct can have multiple levels:
 - can be a component 
 (API GW + Lambda + upload S3 bucket)
 
 - can be a single piece
 (a Lambda) • You write constructs as components

Slide 31

Slide 31 text

simalexan Language support • TypeScript • Python • Java • C#

Slide 32

Slide 32 text

simalexan How does it look like

Slide 33

Slide 33 text

simalexan What would you write?

Slide 34

Slide 34 text

simalexan

Slide 35

Slide 35 text

simalexan How do you start • npm install -g [email protected] • A configured AWS account + AWS CLI

Slide 36

Slide 36 text

simalexan Demo • CDK CLI workflow • Demonstrate the workflow

Slide 37

Slide 37 text

simalexan cdk init • npm install -g aws-cdk • mkdir hello-serverless-banjaluka • cdk init app —-language=typescript
 • Setups the project, lib, bin, cdk.json, tsconfig.json

Slide 38

Slide 38 text

simalexan cdk build • Simply compiles the TypeScript files to javascript • A watch is available too

Slide 39

Slide 39 text

simalexan cdk synth • Synthesizes a template from your CDK app. • A traditional CloudFormation template • Adds AWS::CDK::Metadata to every stack.

Slide 40

Slide 40 text

simalexan cdk diff

Slide 41

Slide 41 text

simalexan cdk deploy

Slide 42

Slide 42 text

simalexan cdk destroy

Slide 43

Slide 43 text

simalexan testing? • Standard testing for your codebase • cdk synth 
 (you can test the CF output) • programmable infrastructure tests

Slide 44

Slide 44 text

simalexan stages? • Standard environment setup with your services • Different AWS accounts, belonging to an an organization • You can setup a CI/CD pipeline with AWS CDK

Slide 45

Slide 45 text

simalexan Next steps • Try out the CDK • https://cdkworkshop.com • https://awslabs.github.io/aws-cdk
 The repository is constantly evolving • https://github/awslabs/aws-cdk

Slide 46

Slide 46 text

simalexan Examples
 https://github.com/aws-samples/aws-cdk-examples A few serverless ones: • api-cors-lambda-crud-dynamodb • appsync-graphql-dynamodb • static-site • fargate-service-with-auto-scaling • … many more

Slide 47

Slide 47 text

simalexan

Slide 48

Slide 48 text

simalexan Questions? @simalexan serverless.pub Twitter Blog “Serverless Applications with Node.js" claudia40 40% off Thank you