-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yml
68 lines (63 loc) · 3.29 KB
/
template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# This is the SAM template that represents the architecture of your serverless application
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html
# The AWSTemplateFormatVersion identifies the capabilities of the template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html
AWSTemplateFormatVersion: 2010-09-09
Description: >-
sam-poc
# Transform section specifies one or more macros that AWS CloudFormation uses to process your template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Transform:
- AWS::Serverless-2016-10-31
# Resources declares the AWS resources that you want to include in the stack
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
Resources:
# This is an SQS queue with all default configuration properties. To learn more about the available options, see
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
SimpleQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: SimpleQueue
# This is the Lambda function definition associated with the source code: sqs-payload-logger.js. For all available properties, see
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
SQSPayloadLogger:
Type: AWS::Serverless::Function
Properties:
FunctionName: SQSPayloadLogger
Description: A Lambda function that logs the payload of messages sent to an associated SQS queue.
Runtime: nodejs12.x
Handler: src/handlers/payload-logger.sqsPayloadLoggerHandler
# This property associates this Lambda function with the SQS queue defined above, so that whenever the queue
# receives a message, the Lambda function is invoked
Events:
SQSQueueEvent:
Type: SQS
Properties:
Queue: !GetAtt SimpleQueue.Arn
MemorySize: 128
Timeout: 25 # Chosen to be less than the default SQS Visibility Timeout of 30 seconds
Policies:
# Give Lambda basic execution Permission to the helloFromLambda
- AWSLambdaBasicExecutionRole
# This is the Lambda function definition associated with the source code: sqs-payload-logger.js. For all available properties, see
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
ApiGatewayPayloadLogger:
Type: AWS::Serverless::Function
Properties:
FunctionName: ApiGatewayPayloadLogger
Description: A Lambda function that logs the payload sent to an associated endpoint.
Runtime: nodejs12.x
Handler: src/handlers/payload-logger.apiGatewayPayloadLoggerHandler
# This property associates this Lambda function with the api defined above, so that whenever the url is invoked
# receives a body, the Lambda function is invoked
Events:
ApiEvent:
Type: Api
Properties:
Path: /test
Method: post
MemorySize: 128
Timeout: 25 # Chosen to be less than the default SQS Visibility Timeout of 30 seconds
Policies:
# Give Lambda basic execution Permission to the helloFromLambda
- AWSLambdaBasicExecutionRole