Deployment automation for an AWS Serverless project

A presentation at AWS Community Day Germany 2019 in September 2019 in Hamburg, Germany by Bruno Amaro Almeida

Slide 1

Slide 1

Deployment automation for an AWS Serverless project: SAM vs CloudFormation vs Terraform vs ServerlessFramework Bruno Amaro Almeida | 9 Sept 2019 @bruno_amaro Community Day 2019 Sponsors

Slide 2

Slide 2

FUTURE. CO-CREATED. Nordic Roots, Global Mindset PEOPLE NATIONALITIES 550+ 38 8 30% OFFICES Tampere Helsinki Oslo Stockholm YoY GROWTH Family of Companies eCommerce & Growth Hacking Berlin London Artificial Intelligence & Machine Learning Stuttgart Munich

Slide 3

Slide 3

Who is this guy? Principal Architect & Technology Advisor @ Futurice ! native, based in ” Cloud, DevOps, Security, Data Engineering & AI Reach out on: @bruno_amaro BERLIN · HELSIN K I · LON DON @brunoamaroalmeida · MUN ICH · OSLO · STOCK HOLM · TAMPERE

Slide 4

Slide 4

Why is Deployment Automation Important? AUTOMATE AND DEPLOY (…) provisions your resources in a safe, repeatable manner, allowing you to build and rebuild your infrastructure and applications, without having to perform manual actions or write custom scripts. source: aws.amazon.com REASONS FOR AUTOMATING INFRASTRUCTURE • Repeatable re-deployable infrastructure • Documented maintainable infrastructure • Scalable solutions • Huge Architectures • Complex systems source: google cloud platform

Slide 5

Slide 5

[UNPOPULAR OPINION]: NOT EVERYTHING NEEDS TO BE AUTOMATED BERLIN · HELSIN K I · LON DON · MUN ICH · OSLO · STOCK HOLM · TAMPERE Photo by Steve Johnson on Unsplash

Slide 6

Slide 6

A ”real-world” Serverless App Frontend • 1 x Static Website: • Displays different options • Allows the visitor to select an option. Backend • 1 x API • Process the chosen option and stores the result. BERLIN · HELSIN K I · LON DON · MUN ICH · OSLO · STOCK HOLM · TAMPERE

Slide 7

Slide 7

A Serverless App What is your favorite German car brand? Audi, Mercedes-Benz or BMW? Visit hello.devopssquad.com today 💚 BERLIN · HELSIN K I · LON DON · MUN ICH · OSLO · STOCK HOLM · TAMPERE

Slide 8

Slide 8

Architecture @bruno_amaro

Slide 9

Slide 9

Athena & QuickSight for Results @bruno_amaro

Slide 10

Slide 10

“ AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment. CloudFormation allows you to use a simple text file to model and provision, in an automated and secure manner, all the resources needed for your applications across all regions and accounts. source: aws.amazon.com

Slide 11

Slide 11

CloudFormation (optional) Parameters Resources (optional) Outputs Other sections (optional): Transforms, Mappings, Conditions, etc

Slide 12

Slide 12

“ The AWS Serverless Application Model extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.” source: aws.amazon.com

Slide 13

Slide 13

CloudFormation SAM Serverless Application Model AWS::IAM::Role AWS::Lambda::Function AWS::Lambda::Permission AWS::ApiGateway::RestApi AWS::ApiGateway::Resource AWS::ApiGateway::Method AWS::ApiGateway::Deployment AWS::ApiGateway::Stage AWS::ApiGateway::Method AWS::Serverless::Api (*) AWS::Serverless::Function AWS::ApiGateway::ApiKey AWS::ApiGateway::UsagePlan AWS::ApiGateway::UsagePlanKey AWS::ApiGateway::DomainName AWS::ApiGateway::BasePathMapping AWS::Route53::RecordSetGroup AWS::S3::Bucket AWS::S3::BucketPolicy @bruno_amaro

Slide 14

Slide 14

Serverless Application Model • Local debugging and testing • Zip the lambda dir & S3 upload • Outputs a new template file ( packaged.yaml ) • Allow publishing to public repository @bruno_amaro

Slide 15

Slide 15

“ Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom inhouse solutions.” source: terraform.io

Slide 16

Slide 16

Terraform • Open Source project from Hashicorp • Multi-Cloud support (AWS, Azure, GCP, etc) • Multiple providers and services to be combined and composed • Separation between planning and execution phase • Module Registry

Slide 17

Slide 17

Terraform Init Plan

Slide 18

Slide 18

Terraform (Optional) Generate resource graph Appl y @bruno_amaro

Slide 19

Slide 19

“ The Serverless Framework helps you build serverless apps with radically less overhead and cost. It provides a powerful, unified experience to develop, deploy, test, secure and monitor your serverless applications. source: serverless.com

Slide 20

Slide 20

Serverless Framework • Open Source project from ServerlessFramework • Basic Multi-Cloud support (AWS, Azure, GCP, etc) • Focus on the core serverless components (e.g. API GW, Lambda, etc) • Ability to include Cloud Formation to extend the functionality

Slide 21

Slide 21

Serverless Framework @bruno_amaro

Slide 22

Slide 22

CloudFormation vs SAM vs Terraform vs ServerlessFramework Pro: Pro: • AWS Native • Extension of AWS CloudFormation • Fully supported by AWS • Ability to local debugging and testing • Easier packaging • AWS SAM Repository • • Free of charge JSON or YAML Serverless Framework Terraform Serverless Application Model CloudFormation Pro Pro • Open Source project from Hashicorp • Open Source project from ServerlessFramework • Module Registry • Multiple providers can be combined • Multi-Cloud support (AWS, Azure, GCP, etc) • Easy to get up and running with basic resources • Basic Multi-Cloud support (AWS, Azure, GCP, etc) Con Con: • Not AWS Native and Support is paid Con : • Hard to troubleshoot • Only covers some AWS Resources ¯_(ツ)/¯ • Not so easy to write templates • Documentation is not at a good level • Couple of workarounds here and there Con • Limited support (purely focused on the traditional serverless resources) ¯_(ツ)/¯ ¯_(ツ)/¯ • Multi-Cloud support • • You still end up writting the usual CF to workaround missing features Resource Graphs • Separate planning and execution phase • Remote state files (chicken or the egg) ¯_(ツ)/¯ • Two separate languages (ie. CF) • Agnostic infra tool ended up being a JS project with 1000+ of frequently updating npm dependencies @bruno_amaro

Slide 23

Slide 23

Thank you! Kiitos! Danke! Tack! Bruno Almeida P RINC IP AL ARC HITE C T & TE C HNOL OGY ADV ISOR Cloud, Security, DevOps, Data Engineering & AI Reach out on: @bruno_amaro @brunoamaroalmeida BERLIN · HELSIN K I · LON DON · MUN ICH · OSLO · STOCK HOLM · TAMPERE