Pépin Rémi, Ensai, 2024
remi.pepin@insee.fr
Possibilité d'agir à différents niveau du traitement. Exemple :
Transform: AWS::Serverless-2016-10-31
Globals:
Set of globals variables. Ex timeout, language etc
Description:
A short text to explain what your template do and how it work
Resources:
Set of resources. Basically the most important part of the template !
Outputs:
Set of outputs like API Gtw url, lambda name, S3 buck name etc
# Appeler une fonction lambda en local avec un json de test
sam local invoke FunctionName --event events/event_file.json
# Lancer une API Gtw en local
sam local start-api
# Récupérer les logs d'une fonction lambda
sam logs -n FunctionName --stack-name sam-app
# Supprimer toute une stack
aws cloudformation delete-stack --stack-name sam-app
Resources:
TasksApi:
Type: AWS::Serverless::Api
Properties:
StageName: prod
CreateTaskFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/handlers/createTask
Handler: app.handler
Events:
PostTaskFunctionApi:
Type: Api
Properties:
RestApiId: !Ref TasksApi
Path: /tasks
Method: POST
GetTasksFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/handlers/getTasks
Handler: app.handler
Events:
GetTasksFunctionApi:
Type: Api
Properties:
RestApiId: !Ref TasksApi
Path: /tasks
Method: GET
Objectifs