-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserverless.yml
More file actions
57 lines (48 loc) · 1.41 KB
/
Copy pathserverless.yml
File metadata and controls
57 lines (48 loc) · 1.41 KB
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
service: serverless-sqs-lambda-sns
provider:
name: aws
stage: ${opt:stage, 'dev'}
runtime: java8
region: eu-west-1
memorySize: 1024
timeout: 120
environment:
sqsUrl:
Ref: SQSQueue
snsArn:
Ref: SNSTopic
iamRoleStatements:
- Effect: Allow
Action:
- sqs:*
Resource:
Fn::GetAtt: [ SQSQueue, Arn ]
- Effect: Allow
Action:
- sns:Publish
- sns:CreateTopic
Resource: { "Fn::Join" : ["", ["arn:aws:sns:${self:provider.region}:", { "Ref" : "AWS::AccountId" }, ":${self:resources.Resources.SNSTopic.Properties.TopicName}" ] ] }
package:
artifact: target/serverless-sqs-lambda-sns-1.0.0.jar
functions:
dequeue:
handler: com.example.Handler
events:
- schedule: rate(2 minutes)
resources:
Resources:
SQSQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:service}-${self:provider.stage}-queue
SNSTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: SNS Topic
TopicName: ${self:service}-${self:provider.stage}-topic
SNSSubscription:
Type: AWS::SNS::Subscription
Properties:
Endpoint: email@provider.com
Protocol: email
TopicArn: { "Fn::Join" : ["", ["arn:aws:sns:${self:provider.region}:", { "Ref" : "AWS::AccountId" }, ":${self:resources.Resources.SNSTopic.Properties.TopicName}" ] ] }