-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.yml
158 lines (153 loc) · 4.62 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: ${self:custom.tenant}-registration
provider:
name: aws
runtime: provided.al2
architecture: arm64
stage: prod
region: eu-central-1
endpointType: REGIONAL
apiGateway:
shouldStartNameWithService: true
memorySize: 512
timeout: 30
deploymentBucket:
name: dasniko.serverless.deployments.${self:provider.region}
logRetentionInDays: 30
environment:
DISABLE_SIGNAL_HANDLERS: 'true'
APP_DYNAMODB_TABLE: ${self:service}
APP_EVENTS_DATA_KEY: registration/${self:custom.tenant}/eventData.json
APP_TENANT_ID: ${self:custom.tenant}
QUARKUS_PROFILE: ${self:custom.tenant}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.APP_DYNAMODB_TABLE}"
- "arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.APP_DYNAMODB_TABLE}/index/*"
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource: "arn:aws:s3:::jugda/*"
- Effect: Allow
Action:
- ses:SendEmail
- ses:SendTemplatedEmail
- ses:SendBulkTemplatedEmail
Resource: ${self:custom.secrets.${self:custom.tenant}Registration.aws.sesIdentity}
- Effect: Allow
Action:
- ses:SendTemplatedEmail
- ses:SendBulkTemplatedEmail
Resource: ${self:custom.secrets.${self:custom.tenant}Registration.aws.sesTemplate}
- Effect: Allow
Action:
- ses:CreateTemplate
- ses:UpdateTemplate
Resource: "*"
custom:
tenant: ${env:TENANT, 'jugda'}
secrets: ${ssm:/aws/reference/secretsmanager/jugda-secrets}
package:
individually: true
functions:
admin:
handler: not.used.in.provided.runtime
events:
- http:
path: /admin/{proxy+}
method: any
authorizer:
name: basicAuthorizer
type: token
identitySource: method.request.header.Authorization
resultTtlInSeconds: 300
package:
artifact: target/function.zip
public:
handler: not.used.in.provided.runtime
environment:
SLACK_OAUTH_ACCESS_TOKEN: ${self:custom.secrets.${self:custom.tenant}Registration.slack.access_token}
SLACK_CHANNEL_GENERAL: ${self:custom.secrets.${self:custom.tenant}Registration.slack.channel_general}
events:
- http:
path: /{proxy+}
method: any
package:
artifact: target/function.zip
basicAuthorizer:
handler: src/main/js/basicAuthorizr.handler
runtime: nodejs18.x
memorySize: 128
timeout: 3
environment:
REGISTRATION_ADMIN: ${self:custom.secrets.${self:custom.tenant}Registration.registration.admin}
REGISTRATION_SECRET: ${self:custom.secrets.${self:custom.tenant}Registration.registration.secret}
package:
include:
- src/main/js/basicAuthorizr.js
exclude:
- "*.*"
- "*/**"
resources:
Resources:
DynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
-
AttributeName: eventId
AttributeType: S
-
AttributeName: email
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 2
TableName: ${self:provider.environment.APP_DYNAMODB_TABLE}
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
SSESpecification:
SSEEnabled: true
GlobalSecondaryIndexes:
-
IndexName: event-email-index
KeySchema:
-
AttributeName: eventId
KeyType: HASH
-
AttributeName: email
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 2
GatewayResponse:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.WWW-Authenticate: "'Basic'"
ResponseType: UNAUTHORIZED
RestApiId:
Ref: ApiGatewayRestApi
StatusCode: 401