-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
158 lines (145 loc) · 4.03 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
service: simple-sell
provider:
name: aws
runtime: nodejs20.x
stage: ${opt:stage, 'dev'}
region: ap-southeast-2
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 'lambda:InvokeFunction'
Resource: "*"
- Effect: Allow
Action:
- "ssm:GetParameter"
Resource: "*"
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
Resource:
- "Fn::GetAtt": [ shopConfigTable, Arn ]
- "Fn::GetAtt": [ orderTable, Arn ]
- Effect: Allow
Action:
- ses:SendEmail
Resource: "*"
environment:
SHOP_CONFIG_TABLE: shop-config-${self:provider.stage} # TODO: grab this from where it's declared
ORDER_TABLE: order-${self:provider.stage} # TODO: grab this from where it's declared
GOOGLE_API_KEY: ${ssm:/api/${self:provider.stage}/google-api-key} # TODO: remove this, just use service account
GOOGLE_SERVICE_ACCOUNT_EMAIL: ${ssm:/api/${self:provider.stage}/google-service-account-email}
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY: ${ssm:/api/${self:provider.stage}/google-service-account-private-key}
WEBSITE_BASE_URL: https://windsongorchard.nz # TODO: figure out how to get this from CF output
ORDER_CREATED_SES_TEMPLATE: orderCreated_${self:provider.stage}
package:
exclude:
- ui/**
- src/**
- cloudformation/**
- Makefile
- scripts/**
include:
- dist/**
- package.json
- package-lock.json
functions:
getShop:
handler: dist/handler.getShop
events:
- http:
path: shop/{shopId}
method: GET
cors: true
checkout:
handler: dist/handler.checkout
events:
- http:
path: shop/{shopId}/checkout
method: post
cors: true
getOrder:
handler: dist/handler.getOrder
events:
- http:
path: shop/{shopId}/order/{orderId}
method: get
cors: true
cancelOrder:
handler: dist/handler.cancelOrder
events:
- http:
path: shop/{shopId}/order/{orderId}/cancel
method: post
cors: true
stripeWebhook:
handler: dist/handler.stripeWebhook
events:
- http:
path: shop/{shopId}/order/webhook
method: post
resources:
Resources:
shopConfigTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: shop-config-${self:provider.stage}
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
orderTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: order-${self:provider.stage}
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "shopId"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
GlobalSecondaryIndexes:
- IndexName: shopId
KeySchema:
- AttributeName: shopId
KeyType: HASH
- AttributeName: id
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Outputs:
TableName:
Value:
Ref: shopConfigTable
Description: Shop configuration table
plugins:
- serverless-domain-manager
- serverless-prune-plugin
- serverless-offline
custom:
prune:
automatic: true
number: 3
includeLayers: true
customDomain:
domainName: ${self:provider.stage}.windsongorchard.nz
certificateName: "*.windsongorchard.nz"
createRoute53Record: true
stage: ${self:provider.stage}
autoDomain: true