-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserverless.yml
More file actions
108 lines (102 loc) · 3.04 KB
/
Copy pathserverless.yml
File metadata and controls
108 lines (102 loc) · 3.04 KB
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
service: ascii-less-gallery
provider:
name: aws
runtime: java8
profiles: sless
timeout: 60
environment:
DYNAMODB_USER_TABLE: ${self:service}-${opt:stage, self:provider.stage}-user
ES_DOMAIN_NAME: es-gallery
REDIS_URL: ${file(serverless-config.yml):${opt:stage, self:provider.stage}.RedisUrl}
REDIS_PORT: ${file(serverless-config.yml):${opt:stage, self:provider.stage}.RedisPort}
ES_URL: ${file(serverless-config.yml):${opt:stage, self:provider.stage}.ElasticsearchUrl}
iamRoleStatements:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource: "*"
- Effect: "Allow"
Action:
- "rekognition:DetectLabels"
Resource: "*"
- Effect: "Allow"
Action:
- "es:ESHttpDelete"
- "es:ESHttpGet"
- "es:ESHttpPost"
- "es:ESHttpPut"
Resource: "arn:aws:es:${opt:region, self:provider.region}:*:domain/${self:provider.environment.ES_DOMAIN_NAME}/*"
- Effect: Allow
Action:
- "dynamodb:GetItem"
- "dynamodb:PutItem"
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_USER_TABLE}"
package:
artifact: build/distributions/ascii-gallery.zip
functions:
# Auth function
auth:
handler: ajurasz.lambda.auth.ValidateHandler
# Account functions
login:
handler: ajurasz.lambda.auth.LoginHandler
events:
- http:
path: login
method: post
register:
handler: ajurasz.lambda.auth.RegisterHandler
events:
- http:
path: register
method: post
# Gallery functions
create:
handler: ajurasz.lambda.gallery.CreateHandler
events:
- http:
path: gallery
method: post
integration: lambda
request:
passThrough: WHEN_NO_TEMPLATES
template:
image/png: '{ "operation" : "create", "base64Image" : "$input.body", "principalId" : "$context.authorizer.principalId" }'
authorizer:
name: auth
resultTtlInSeconds: 30
identitySource: method.request.header.token
list:
handler: ajurasz.lambda.gallery.ListHandler
events:
- http:
path: gallery
method: get
delete:
handler: ajurasz.lambda.gallery.DeleteHandler
events:
- http:
path: gallery/{id}
method: delete
authorizer:
name: auth
resultTtlInSeconds: 30
identitySource: method.request.header.token
resources:
Resources:
UserTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: ${file(serverless-config.yml):${opt:stage, self:provider.stage}.DeletionPolicy}
Properties:
AttributeDefinitions:
-
AttributeName: email
AttributeType: S
KeySchema:
-
AttributeName: email
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_USER_TABLE}