OVERVIEW
- Serverless Application Model
- Framework for developing and deploying serverless applications
- All config is in the
YAMLformat - Lambda function
- DynamoDB table
- API Gateway
- Cognito User Pool
SAMhelp to run followings locally- API Gateway
- DynamoDB Table
SAMhelp to integrateCode Deploy, soLambda Functionscan deploy easily- Allow test the
Lambda functionlocally - Can invoke
functionandeventslocally SAM Templatescan be used to test the app through before deploy- Using
SAM Built In Code Deploy, application can be deployed to the cloud - SAM can run locally using SAM CLI + AWS ToolKit for local testing and debugging
SAM Policy Templates: To access resource, we need to add IAM roles to the Lambda,SAM Policy Templatescan be used instead
Running SAM locally
- In AWS, a lambda has associated role and aws context to invoke other services
- In local, to allow access other services from lambda
- First create a profile
- When invoke, use the profile as parameter
SAM & CodeDeploy
- CodeDeploy is integrated closely with the SAM
- Anytime we update a Lambda function, the CodeDeploy play the role of deployment
- Properties
AutoPublishAlias: Detect when new code is being updatedDeploymentPreference: Determine how the code deployment will work- Linear
- Canary
- All At Once
- Alarms: To trigger rollback
- Hooks: Can run before and after traffic shifting in the new Lambda function
SAM Local Capabilities
- We can start and invoke Lambda function
sam local start-lambdafor starting a local endpointsam local invoketo invoke a lambda with payloadinvokeis for run once and then quit whilestart-lambdakeeps the endpoint open for function invocationsam local start-apifor run local HTTP server for theAPI Gatewaysam local generate-eventfor generate sample event sources from services like S3, SNS, SQS etc
SAR
- Serverless application repository
- Used to store SAM app in the repository, so we can use
- Publicly
- Defined Account
- Use for reduce code duplication using
- Environment variables
- Directly mention