sept19 awsgermany deployment automation for an aws ... automation f… · amazon api gateway apis,...

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

Upload: others

Post on 20-May-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Deployment automation for an AWS Serverless project: SAM vs CloudFormation vs Terraform vs ServerlessFrameworkBruno Amaro Almeida | 9 Sept 2019

Community Day 2019 Sponsors

@bruno_amaro

Page 2: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Helsinki

Tampere

StockholmOslo

LondonBerlin

Munich

Nordic Roots,Global Mindset

FU T U R E . C O - C R E A T E D .

P E OP LE

550+NATIONALITIE S

38OFFICE S

8YoY GROW TH

30%Family of Companies

eCommerce &Growth Hacking

Artificial Intelligence& Machine Learning

Stuttgart

Page 3: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

B E R L I N · H E L S I N K I · L O N D O N · M U N I C H · O S L O · S T O C K H O L M · T A M P E R E

Who is this guy?Principal Architect & Technology Advisor @ Futurice

native, based in

Cloud, DevOps, Security, Data Engineering & AI

@brunoamaroalmeida

@bruno_amaro

Reach out on:

! "

Page 4: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

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.

Why is Deployment Automation Important?

source: aws.amazon.com

REASONS FOR AUTOMATING INFRASTRUCTURE

• Repeatable re-deployable infrastructure

• Documented maintainable infrastructure

• Scalable solutions

• Huge Architectures

• Complex systemssource: google cloud platform

Page 5: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

B E R L I N · H E L S I N K I · L O N D O N · M U N I C H · O S L O · S T O C K H O L M · T A M P E R E

[UNPOPULAR OPINION]: NOT EVERYTHING NEEDS TO BE AUTOMATED

Photo by Steve Johnson on Unsplash

Page 6: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

B E R L I N · H E L S I N K I · L O N D O N · M U N I C H · O S L O · S T O C K H O L M · T A M P E R E

A ”real-world" Serverless AppFrontend

• 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.

Page 7: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

B E R L I N · H E L S I N K I · L O N D O N · M U N I C H · O S L O · S T O C K H O L M · T A M P E R E

A Serverless App

What is your favoriteGerman car brand?

Audi, Mercedes-Benz or BMW?

Visit hello.devopssquad.com today 💚

Page 8: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Architecture

@bruno_amaro

Page 9: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Athena & QuickSight for Results

@bruno_amaro

Page 10: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

“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

Page 11: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

(optional) Parameters

CloudFormation

Resources

(optional) OutputsOther sections (optional): Transforms, Mappings, Conditions, etc

Page 12: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

“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

Page 13: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Serverless Application ModelAWS::IAM::RoleAWS::Lambda::FunctionAWS::Lambda::PermissionAWS::ApiGateway::RestApiAWS::ApiGateway::ResourceAWS::ApiGateway::MethodAWS::ApiGateway::DeploymentAWS::ApiGateway::StageAWS::ApiGateway::Method

AWS::Serverless::Api (*)AWS::Serverless::Function

AWS::ApiGateway::ApiKeyAWS::ApiGateway::UsagePlanAWS::ApiGateway::UsagePlanKeyAWS::ApiGateway::DomainNameAWS::ApiGateway::BasePathMappingAWS::Route53::RecordSetGroupAWS::S3::BucketAWS::S3::BucketPolicy

CloudFormation SAM

@bruno_amaro

Page 14: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Serverless Application Model

• Zip the lambda dir & S3 upload

• Outputs a new template file ( packaged.yaml )

• Local debugging and testing

• Allow publishing to public repository

@bruno_amaro

Page 15: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

“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 in-house solutions.”

source: terraform.io

Page 16: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

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

Page 17: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Terraform

Plan

Init

Page 18: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Terraform

Apply

(Optional) Generate resource graph

@bruno_amaro

Page 19: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

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

source: serverless.com

Page 20: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

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

Page 21: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Serverless Framework

@bruno_amaro

Page 22: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

CloudFormation vs SAM vs Terraform vs ServerlessFramework

Pro:

• AWS Native

• Fully supported by AWS

• Free of charge

• JSON or YAML

Con:

• Hard to troubleshoot

¯\_(ツ)_/¯

• Not so easy to write templates

• Documentation is not at a good level

CloudFormation Serverless Application Model Terraform

Pro:

• Extension of AWS CloudFormation

• Ability to local debuggingand testing

• Easier packaging

• AWS SAM Repository

Con:

• Only covers some AWS Resources

¯\_(ツ)_/¯

• You still end up writting theusual CF to workaroundmissing features

Pro

• Open Source project from Hashicorp

• Module Registry

• Multiple providers can be combined

• Multi-Cloud support (AWS, Azure, GCP, etc)

Con

• Not AWS Native and Support is paid

• Couple of workarounds here and there

¯\_(ツ)_/¯

• Multi-Cloud support

• Resource Graphs

• Separate planning and execution phase

• Remote state files (chicken or the egg)

Serverless FrameworkPro

• Open Source project fromServerlessFramework

• Easy to get up and running with basic resources

• Basic Multi-Cloud support (AWS, Azure, GCP, etc)

Con

• Limited support (purely focused on the traditional serverlessresources)

¯\_(ツ)_/¯

• Two separate languages (ie. CF)

• Agnostic infra tool ended up being a JS project with 1000+ of frequentlyupdating npm dependencies

@bruno_amaro

Page 23: Sept19 AWSGermany Deployment automation for an AWS ... automation f… · Amazon API Gateway APIs, AWS Lambda functions, and ... Terraformis a tool for building, changing, and versioning

Thank you!Kiitos!Danke!Tack!

B E R L I N · H E L S I N K I · L O N D O N · M U N I C H · O S L O · S T O C K H O L M · T A M P E R E

Bruno AlmeidaPRINCIPAL ARCHITECT & TECHNOLOGY ADVISOR

Cloud, Security, DevOps, Data

Engineering & AI

@brunoamaroalmeida

@bruno_amaro

Reach out on: