-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
106 lines (99 loc) · 2.75 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Transform: AWS::Serverless-2016-10-31
Parameters:
APIDomainName:
Type: String
Default: api.tempfeedback.com
Description: The domain name for the feedback API
APICertificateArn:
Type: String
Description: The AWS Certificate Manager ARN for the given domain name
Resources:
TempFeedbackTable:
Type: AWS::Serverless::SimpleTable
Properties:
TableName: TempFeedback
PrimaryKey:
Name: subdomain
Type: String
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TempFeedbackAPI:
Type: AWS::Serverless::HttpApi
Properties:
Domain:
DomainName: !Ref APIDomainName
CertificateArn: !Ref APICertificateArn
CorsConfiguration:
AllowHeaders:
- authorization
- content-type
- "*"
AllowMethods:
- "*"
AllowOrigins:
- "*"
AddFeedbackFunction:
Type: AWS::Serverless::Function
Properties:
Handler: AddFeedback.handler
Runtime: nodejs14.x
CodeUri: lambdas/AddFeedback
Policies:
- DynamoDBWritePolicy:
TableName: !Ref TempFeedbackTable
Events:
HttpApiEvent:
Type: HttpApi
Properties:
Path: /AddFeedback
Method: POST
ApiId: !Ref TempFeedbackAPI
CreateSubdomainFunction:
Type: AWS::Serverless::Function
Properties:
Handler: CreateSubdomain.handler
Runtime: nodejs14.x
CodeUri: lambdas/CreateSubdomain
Policies:
- DynamoDBWritePolicy:
TableName: !Ref TempFeedbackTable
Events:
HttpApiEvent:
Type: HttpApi
Properties:
Path: /CreateSubdomain
Method: POST
ApiId: !Ref TempFeedbackAPI
DeleteOldSubdomainsFunction:
Type: AWS::Serverless::Function
Properties:
Handler: DeleteOldSubdomains.handler
Runtime: nodejs14.x
CodeUri: lambdas/DeleteOldSubdomains
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref TempFeedbackTable
Events:
CWSchedule:
Type: Schedule
Properties:
Description: Run DeleteOldSubdomainsFunction every day
Schedule: rate(1 day)
Enabled: True
GetFeedbackFromSubdomainFunction:
Type: AWS::Serverless::Function
Properties:
Handler: GetFeedbackFromSubdomain.handler
Runtime: nodejs14.x
CodeUri: lambdas/GetFeedbackFromSubdomain
Policies:
- DynamoDBReadPolicy:
TableName: !Ref TempFeedbackTable
Events:
HttpApiEvent:
Type: HttpApi
Properties:
Path: /GetFeedbackFromSubdomain
Method: GET
ApiId: !Ref TempFeedbackAPI