These days it is crucial to be conscious of the time spent on setting up the AWS accounts. AWS Serverless Application Repository is a way to deploy parametrized applications written with AWS SAM. However, AWS CDK proved that everything is a code now. So I will show how to unite the tools to deploy and publish the application, potentially saving thousands of hours for the development teams. With Serverless Application Repository, SAM, and CDK, one could set up monitoring and alert for different applications situated in a multi-account environment. I will show how it helped one of my clients save monotonous work hours.
Diamond Application Development Crafting Solutions with Precision
Eliminate repetitive work by using AWS Serverless Application Repository
1. Igor Soroka, 11/05/2022, AWS Summit Stockholm
Eliminate repetitive work by
using AWS Serverless
Application Repository
2. #whoami
• Serverless Consultant
• 6 x AWS Certi
fi
cates
• AWS Community Builder
• Blogger, Speaker, Trainer
• Twitter: @grenguar
• Avid runner
3. Agenda
• Use case and Motivation
• AWS SAM, AWS CDK, AWS Serverless Application Repository
• Custom AWS Lambda Packing and TypeScript support
• AWS Lambda Layers
4. Use Case
• Online shop
• ±50 AWS Accounts for every API, ETL and front-end parts
• Monitoring API connected to ElasticSearch with PagerDuty
• Amazon CloudWatch Alarms
5. Motivation
Start with Why
• Dozens of repetitive tasks for every AWS account
• Automation of account monitoring setup
• Provisioning Amazon CloudWatch Alarms to the Amazon SQS
automatically by RegEx
• Uploading custom JSON
fi
les to Amazon S3 for creating watchers
(4xx, 5xx, custom errors)
6. How tools are interconnected?
• AWS Serverless Application Repository needs SAM for publishing
• AWS SAM could create layers according to instructions set in
Make
fi
le/Metadata
• AWS CDK was used to write Infrastructure as Real code (with
TypeScript)
• Sam-beta-cdk - CLI tool for uniting AWS CDK and AWS SAM
7. Tools we used
What are they?
• The AWS Serverless Application Model is an open-source
framework for building serverless applications
• The AWS Cloud Development Kit is an open-source software
development framework to de
fi
ne cloud resources with familiar
programming languages
• The AWS Serverless Application Repository is a managed
repository for serverless applications
11. AWS Serverless Application Repository: Why?
• One stop for serverless applications
• Sharing between accounts by setting up the Application policy
• Parametrised and versioned CloudFormation template
12. It needs Application Metadata
• Name of application, version, readme and license are needed
13. AWS SAM Lambda Typescript Support
It could use ESBuild directly - 25.02.2022
14. Metadata for AWS Lambda
Custom build steps
• The AWS::Serverless::Function supports building custom runtimes
• Set of instructions
15. AWS Lambda Layers
• Layer is like AWS Lambda function but without handler
• It could pack the function dependencies and shared code
• Could be reused across lambdas
17. AWS CDK and AWS SAM
sam-beta-cdk
• The tool which is created to unite them
• The building stage creates the AWS CDK and AWS SAM projects
• It generates a valid AWS SAM project which could be deployed with
SAM CLI
18. Key Findings
• Metadata resource attribute in AWS Lambda functions
• Usage of AWS Lambda Layers to share function dependencies
• AWS CDK could be used with AWS SAM with `sam-beta-cdk`
• AWS SAM with AWS CDK could be used as a
fi
rst step of infra
migration
19. Thank you for your attention!
Let’s go and build awesome serverless
applications