-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
80 lines (72 loc) · 2.04 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
service: rwp-webhook
package:
individually: true
plugins:
- serverless-bundle
- serverless-iam-roles-per-function
- serverless-disable-request-validators
- serverless-reqvalidator-plugin
custom:
bundle:
aliases:
- '@': ../../lib/
forceExclude:
- '@aws-sdk/client-apigatewaymanagementapi'
- '@aws-sdk/client-dynamodb'
- '@aws-sdk/client-sns'
- '@aws-sdk/util-dynamodb'
provider:
name: aws
runtime: nodejs18.x
stage: ${opt:stage, 'prod'}
profile: aurdalgroup-${self:provider.stage}
region: ${opt:region, 'eu-west-1'}
logRetentionInDays: 14
# Link to existing API GW
apiGateway:
restApiId: !Ref ApiGatewayRestApi
restApiRootResourceId: !GetAtt ApiGatewayRestApi.RootResourceId
functions:
webhook:
handler: webhook.main
name: rwp-${self:provider.stage}-webhook-webhook
timeout: 30
environment:
WEBSOCKETS_TOPIC_ARN: !ImportValue WebsocketsTopicArn
iamRoleStatements:
- Effect: Allow
Action:
- sns:Publish
Resource: !ImportValue WebsocketsTopicArn
events:
- http:
path: webhook
method: post
cors: true
resources:
Resources:
# Define REST API GW
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: rwp-${self:provider.stage}-webhook-rest
Description: REST API.
4XXGatewayResponse:
Type: AWS::ApiGateway::GatewayResponse
Properties:
ResponseType: DEFAULT_4XX
RestApiId: !Ref ApiGatewayRestApi
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseTemplates:
application/json: '{"error":$context.error.messageString}'
Outputs:
ApiGatewayRestApiId:
Value: !Ref ApiGatewayRestApi
Export:
Name: ApiGatewayRestApiId
ApiGatewayRestApiRootResourceId:
Value: !GetAtt ApiGatewayRestApi.RootResourceId
Export:
Name: ApiGatewayRestApiRootResourceId