-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yaml
84 lines (75 loc) · 2.25 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'SAM Template for the City Tasks Events project.'
Globals:
Function:
Timeout: 20
MemorySize: 512
Runtime: provided.al2
Architectures:
- arm64
Resources:
CityEventsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'Events'
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: deviceId
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: deviceId
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
CityEventsDLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: 'EventsDLQ'
CityEventsFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: 'city-events-function'
CodeUri: .
Handler: org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest
Description: 'Events Lambda function with a DynamoDB table and a DLQ.'
Events:
TaskExecutionEvent:
Type: EventBridgeRule
Properties:
Pattern:
source:
- com.hiperium.city.tasks.api
detail-type:
- TaskExecutionEvent
Policies:
- DynamoDBWritePolicy:
TableName: !Ref CityEventsTable
- SQSSendMessagePolicy:
QueueName: !GetAtt CityEventsDLQ.QueueName
Environment:
Variables:
CITY_TIME_ZONE_ID: '-05:00'
JAVA_TOOL_OPTIONS: '-XX:+TieredCompilation -XX:TieredStopAtLevel=1'
Metadata:
BuildMethod: makefile
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/lambda/${CityEventsFunction}"
RetentionInDays: 7
Outputs:
CityEventsFunction:
Description: 'Events Lambda function ARN.'
Value: !GetAtt CityEventsFunction.Arn
MyDLQArn:
Description: 'Events function DLQ ARN.'
Value: !GetAtt CityEventsDLQ.Arn
CityEventsTable:
Description: 'Events DynamoDB table ARN.'
Value: !GetAtt CityEventsTable.Arn
CityEventsFunctionIamRole:
Description: 'Implicit IAM Role ARN created for the Events function.'
Value: !GetAtt CityEventsFunctionRole.Arn