-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserverless.yml
132 lines (127 loc) · 3.92 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
service: cashburndown-service
provider:
name: aws
runtime: nodejs4.3
region: us-west-2
stage: dev
cognitoRole: Cognito_CashflowBurndownAuth_Role
plaidEnv: tartan
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:*"
Resource:
- "arn:aws:dynamodb:${self:provider.region}:*:table/Accounts-${self:custom.stage}"
custom:
stage: ${opt:stage, self:provider.stage}
cognitoRole: ${opt:cognito_role, self:provider.cognitoRole}
writeEnvVars:
SERVERLESS_STAGE: ${self:custom.stage}
PLAID_CLIENT_ID: ${opt:plaid_client_id}
PLAID_CLIENT_SECRET: ${opt:plaid_client_secret}
PLAID_ENV: ${opt:plaid_env, self:provider.plaidEnv}
ACCOUNTS_TABLE: "Accounts-${self:custom.stage}"
plugins:
- serverless-plugin-write-env-vars
package:
include:
- node_modules
- src
functions:
getAccounts:
handler: index.getAccounts
events:
- http:
path: accounts
method: get
cors: true
deleteAccount:
handler: index.deleteAccount
events:
- http:
path: accounts/{id}
method: delete
cors: true
updateAccountBurndown:
handler: index.updateAccountBurndown
events:
- http:
path: accounts/{id}/burndown
method: put
cors: true
createToken:
handler: index.createToken
events:
- http:
path: tokens
method: post
cors: true
getBurndown:
handler: index.getBurndown
events:
- http:
path: burndowns/{burndownType}
method: get
cors: true
resources:
Resources:
ApiGatewayMethodAccountsIdVarDelete:
Properties:
AuthorizationType: AWS_IAM
Integration:
Credentials: 'arn:aws:iam::*:user/*' #sets "Invoke with caller credentials
ApiGatewayMethodAccountsIdVarBurndownPut:
Properties:
AuthorizationType: AWS_IAM
Integration:
Credentials: 'arn:aws:iam::*:user/*' #sets "Invoke with caller credentials
ApiGatewayMethodAccountsGet:
Properties:
AuthorizationType: AWS_IAM
Integration:
Credentials: 'arn:aws:iam::*:user/*' #sets "Invoke with caller credentials
ApiGatewayMethodTokensPost:
Properties:
AuthorizationType: AWS_IAM
Integration:
Credentials: 'arn:aws:iam::*:user/*' #sets "Invoke with caller credentials
ApiGatewayMethodBurndownsBurndowntypeVarGet:
Properties:
AuthorizationType: AWS_IAM
Integration:
Credentials: 'arn:aws:iam::*:user/*' #sets "Invoke with caller credentials
AccountsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: "Accounts-${self:custom.stage}"
AttributeDefinitions:
- AttributeName: identityId
AttributeType: S
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: identityId
KeyType: HASH
- AttributeName: id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
AccessCashBurndownService:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: "Policy to assign to Cognito 'Authenticated' Role"
Path: "/"
Roles:
- "${self:custom.cognitoRole}"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action: "execute-api:Invoke"
Resource: { "Fn::Join" : ["", ["arn:aws:execute-api:",{"Ref":"AWS::Region"},":",{"Ref":"AWS::AccountId"},":",{"Ref":"ApiGatewayRestApi"},"/*"]]}
-
Effect: "Allow"
Action: "lambda:InvokeFunction"
Resource: { "Fn::Join" : ["", ["arn:aws:lambda:",{"Ref":"AWS::Region"},":",{"Ref":"AWS::AccountId"},":function:cashburndown-service-","${self:custom.stage}","-*"]]}