-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
89 lines (84 loc) · 2.69 KB
/
serverless.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
service: aoc-slack-notifier
provider:
name: aws
runtime: java11
timeout: 20
region: ${opt:region, 'eu-west-2'}
iamRoleStatements:
- Effect: Allow
Action:
- sqs:CreateQueue
- sqs:DeleteMessage
- sqs:ReceiveMessage
- sqs:SendMessage
Resource: arn:aws:sqs:*:*:${self:custom.sqsQueue}
# - Effect: Allow
# Action:
# - SNS:Publish
# - SNS:CreateTopic
# Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.snsTopic}" ] ] }
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:custom.dynamodbTable}"
custom:
# snsTopic: "${self:service}-${self:provider.stage}-compare-event-sns"
sqsQueue: "${self:service}-${self:provider.stage}-compare-event-sqs"
dynamodbTable: AOC_Polling_Event
package:
artifact: target/slack-notifier-0.0.1-SNAPSHOT-aws.jar
functions:
polling:
handler: com.ctl.aoc.slacknotifier.handlers.PollingHandler
events:
- schedule: ${opt:schedule, 'cron(0 */4 * * ? *)'}
environment:
FUNCTION_NAME: pollingFunction
AOC_SESSION_ID: ${opt:sessionid}
# SNS_TOPIC: ${self:custom.snsTopic}
SQS_QUEUE_NAME: ${self:custom.sqsQueue}
compare:
handler: com.ctl.aoc.slacknotifier.handlers.CompareHandler
environment:
FUNCTION_NAME: compareFunction
SLACK_TOKEN: ${opt:slackToken}
events:
- sqs:
arn: { "Fn::Join": ["", ["arn:aws:sqs:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.sqsQueue}" ] ] }
batchSize: 2
# - sns: ${self:custom.snsTopic}
resources:
Resources:
# SnsTopic:
# Type: 'AWS::SNS::Topic'
# DeletionPolicy: Delete
# Properties:
# DisplayName: ${self:custom.snsTopic}
# TopicName: ${self:custom.snsTopic}
SQSQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqsQueue}
MessageRetentionPeriod: 120
VisibilityTimeout: 30
PollingDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: identifier
AttributeType: S
- AttributeName: timestamp
AttributeType: N
KeySchema:
- AttributeName: identifier
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
TableName: ${self:custom.dynamodbTable}