-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
75 lines (68 loc) · 2.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
service: aws-nodejs
plugins:
- serverless-pseudo-parameters
- serverless-sam
custom:
stage: ${opt:stage, self:provider.stage}
region: ${opt:region, "us-east-1"}
dev:
api_id: "5ymkmf7cz7"
prod:
api_id: "npaohfu58k"
api_url: "https://${self:custom.${self:custom.stage}.api_id}.execute-api.${self:custom.region}.amazonaws.com/${self:custom.stage}"
provider:
name: aws
runtime: nodejs6.10
region: ${self:custom.region}
iamRoleStatements:
- Effect: Allow
Action: dynamodb:scan
Resource: arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/restaurants-${self:custom.stage}
- Effect: Allow
Action: execute-api:Invoke
Resource: arn:aws:execute-api:#{AWS::Region}:#{AWS::AccountId}:*/*/GET/restaurants
functions:
get-index:
handler: functions/get-index.handler
events:
- http:
path: /
method: get
environment:
restaurants_api: ${self:custom.api_url}/restaurants
cognito_user_pool_id: us-east-1_BXKvdrj8y
cognito_client_id: 5jocffapd6kamako57uoscfsgu
get-restaurants:
handler: functions/get-restaurants.handler
events:
- http:
path: /restaurants/
method: get
authorizer: aws_iam
environment:
restaurants_table: restaurants-${self:custom.stage}
search-restaurants:
handler: functions/search-restaurants.handler
events:
- http:
path: /restaurants/search
method: post
authorizer:
arn: arn:aws:cognito-idp:#{AWS::Region}:#{AWS::AccountId}:userpool/us-east-1_BXKvdrj8y
environment:
restaurants_table: restaurants-${self:custom.stage}
resources:
Resources:
restaurantsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: restaurants-${self:custom.stage}
AttributeDefinitions:
- AttributeName: name
AttributeType: S
KeySchema:
- AttributeName: name
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1