AWS Sam
Commands
sam build
sam deploy [--guided]
sam delete
- Create pipeline:
cd aws-lab && sam pipeline init --bootstrap
- Validate SAM template:
cd aws-lab && sam validate
- Test Function in the Cloud:
cd aws-lab && sam sync --stack-name {stack-name} --watch
Get start with SAM
Deploy first times
Lambda in hello-word
folder:
Add follow-paris-lambda-1
folder lambda
Add FollowParisLambda1 resource in template.yaml
file:
# ...
FollowParisLambda1:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: follow-paris-lambda-1/
Handler: app.lambdaHandler
Runtime: nodejs20.x
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /lambda-1
Method: get
Metadata: # Manage esbuild properties
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: es2020
Sourcemap: true
EntryPoints:
- app.ts
# ...
Create follow-paris-lambda-1
project, and run npm init
to init project.
{
...,
"devDependencies": {
"@types/aws-lambda": "^8.10.134",
"@types/node": "^20.11.24",
"typescript": "^5.3.3"
},
"dependencies": {
"esbuild": "^0.20.1"
}
}
Deploy second times
Add First Python Lambda
Add FollowParisLambdaConverHtmlToPdf resource in template.yaml
file:
Resources:
# ...
FollowParisLambdaConverHtmlToPdf:
# ...
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: python-follow-paris-lambda-convert-html-to-pdf/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /lambda-convert-html-to-pdf
Method: get
# ...
Create python-follow-paris-lambda-convert-html-to-pdf
folder.
Deploy
Question
- Triggering one AWS lambda from another using the serverless framework: https://medium.com/tech-carnot/triggering-one-aws-lambda-from-another-using-the-serverless-framework-816006b27b8f
Resources
- AWS SAM Tutorial (with a Lambda Example!): https://www.youtube.com/watch?v=MipjLaTp5nA
- AWS Sam
template.yaml
APIs: https://github.com/aws/serverless-application-model/blob/master/docs/globals.rst - aws-step-functions-saga-pattern-with-sam: https://github.com/aws-samples/aws-step-functions-saga-pattern-with-sam
- Security
- AWS SSM Parameter Store and AWS SecretsManager in AWS SAM templates (Sessions with SAM: S2E1): https://www.youtube.com/watch?v=fL3ToMdoXDw
- Middelware