-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
97 lines (88 loc) · 2.95 KB
/
template.yaml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: api-access-tracker-backend
Description: A simple AWS serverless backend, for tracking and logging API request details to a webservice.
Author: Actigence Solutions
SpdxLicenseId: MIT
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: ['lambda', 'dynamodb', 'sqs']
HomePageUrl: https://github.com/Actigence/api-access-tracker-backend
SemanticVersion: 0.0.1
SourceCodeUrl: https://github.com/Actigence/api-access-tracker-backend
Description: >
A simple AWS serverless backend, for tracking and logging API request details to a webservice.
Globals:
Function:
Timeout: 10
Resources:
# Lambda function mapping for consuming items in inbound request queue from SQS and writing them to DynamoDB
InboundRequestConsumerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: server/
Handler: app.inboundRequestQueueConsumer
Runtime: nodejs12.x
Policies:
- SQSPollerPolicy:
QueueName: !GetAtt InboundRequestLoggingQueue.QueueName
- DynamoDBCrudPolicy:
TableName: !Ref InboundAPIAccessLogs
Events:
ShortCodeGenerationSQSEvent:
Type: SQS
Properties:
Queue: !GetAtt InboundRequestLoggingQueue.Arn
BatchSize: 1
Environment:
Variables:
INBOUND_TABLE_NAME: !Ref InboundAPIAccessLogs
# Lambda function mapping for consuming items in Outtbound request queue from SQS and writing them to DynamoDB
OutboundRequestConsumerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: server/
Handler: app.outboundRequestQueueConsumer
Runtime: nodejs12.x
Policies:
- SQSPollerPolicy:
QueueName: !GetAtt OutboundRequestLoggingQueue.QueueName
- DynamoDBCrudPolicy:
TableName: !Ref OutboundAPIAccessLogs
Events:
ShortCodeGenerationSQSEvent:
Type: SQS
Properties:
Queue: !GetAtt OutboundRequestLoggingQueue.Arn
BatchSize: 1
Environment:
Variables:
OUTBOUND_TABLE_NAME: !Ref OutboundAPIAccessLogs
#DynamoDB Tables to store API invocation events
InboundAPIAccessLogs:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: id
Type: String
TableName: aal_inbound_api_access_logs
#DynamoDB Tables to store API invocation events
OutboundAPIAccessLogs:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: id
Type: String
TableName: aal_outbound_api_access_logs
#SQS Definitions
InboundRequestLoggingQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: aal_inbound_request_logging_queue
#SQS Definitions
OutboundRequestLoggingQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: aal_outbound_request_logging_queue