-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
81 lines (74 loc) · 2.27 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
service:
name: moneybutton-webhook-proxy
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
- serverless-offline-sns
- serverless-offline
provider:
name: aws
runtime: nodejs10.x
region: ${opt:region, 'ap-southeast-1'}
memorySize: 128
usagePlan:
rateLimit: ${opt:rateLimit,'2'}
burstLimit: ${opt:burstLimit,'8'}
iamRoleStatements:
- Effect: 'Allow'
Action:
- 'sns:Publish'
Resource:
Ref: WebhookNotificationTopic
custom:
webpack:
includeModules: true
keepOutputDirectory: true
serverless-offline-sns:
port: 4002
debug: true
functions:
webhook:
handler: src/functions/webhook.handle
environment:
TOPIC_ARN:
Ref: WebhookNotificationTopic
WEBHOOK_SECRET: ${ssm:moneybuttonWebhookProxySecret}
events:
- http:
method: post
path: webhook
processSNSMessage:
handler: src/functions/processSNSMessage.middyHandler
environment:
TARGET_ENDPOINT: ${opt:targetEndpoint}
REQUEST_TIMOUT: ${opt:endpointTimeout,'5000'}
TOPIC_ARN:
Ref: WebhookNotificationTopic
events:
- http:
method: post
path: processSNSMessage
resources:
Resources:
WebhookNotificationTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: 'Topic for delivery of webhook notifications to target endpoint'
ProcessMessageSubscription:
Type: AWS::SNS::Subscription
Properties:
Protocol: 'https'
DeliveryPolicy: "{\"healthyRetryPolicy\":{\"minDelayTarget\":${env:SNS_MIN_DELAY,'120'},\"maxDelayTarget\":${env:SNS_MAX_DELAY,'600'},\"numRetries\":11,\"numMaxDelayRetries\":${env:POST_BACKOFF_RETRIES,'2'},\"numNoDelayRetries\": ${env:IMMEDIATE_RETRIES,'1'},\"numMinDelayRetries\": ${env:PRE_BACKOFF_RETRIES,'2'},\"backoffFunction\":\"exponential\"}}"
TopicArn:
Ref: WebhookNotificationTopic
Endpoint:
Fn::Join:
- ""
- - "https://"
- Ref: "ApiGatewayRestApi"
- ".execute-api.${self:provider.region}.amazonaws.com/${self:provider.stage}/processSNSMessage"
Outputs:
WebhookNotificationTopicARN:
Description: ARN of WebhookNotificationTopic Endpoint
Value:
Ref: WebhookNotificationTopic