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
A presentation at AWS Community Day Germany 2019 in September 2019 in Hamburg, Germany by Bruno Amaro Almeida
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
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
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
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
[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
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
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
Architecture @bruno_amaro
Athena & QuickSight for Results @bruno_amaro
“ 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
CloudFormation (optional) Parameters Resources (optional) Outputs Other sections (optional): Transforms, Mappings, Conditions, etc
“ 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
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
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
“ 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
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
Terraform Init Plan
Terraform (Optional) Generate resource graph Appl y @bruno_amaro
“ 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
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
Serverless Framework @bruno_amaro
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
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