-
Notifications
You must be signed in to change notification settings - Fork 5
/
serverless.yml
executable file
·120 lines (111 loc) · 3.16 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
service: <%= appname %>-services
package:
include:
- "lib/*"
- "node_modules/**"
exclude:
- "*.mp3"
- "test/*"
- "src/*"
- ".git/**"
- "ssl/**"
custom:
stage: "${opt:stage, self:provider.stage}"
region: "${opt:region, self:provider.region}"
provider:
name: aws
runtime: nodejs6.10
profile: <%= appname %>
stage: dev
region: us-east-1
functions:
foo:
environment: ${file(env.yml):${self:custom.stage}}
description: lorem ipsum
handler: lib/foo.handler
timeout: 5
memorySize: 1536
events:
- http:
method: get
path: accounting/authorize
cors: true
bar:
description: lorem ipsum
handler: lib/bar.handler
timeout: 2
memorySize: 1024
environment: ${file(env.yml):${self:custom.stage}}
baz:
description: lorem ipsum
handler: lib/baz.handler
environment: ${file(env.yml):${self:custom.stage}}
timeout: 2
memorySize: 1024
iamRoleStatements:
- Effect: Allow
Action:
- lambda:InvokeFunction
events:
- http:
method: post
path: accounting/sync
cors: true
resources:
Resources:
# ROLES
# -----------------------------------------------------------
accounting:
Type: AWS::IAM::Role
Properties:
RoleName: <%= appname %>-services-${self:custom.stage}-accounting
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
# POLICIES
# -----------------------------------------------------------
logging:
Type: AWS::IAM::Policy
Properties:
PolicyName: <%= appname %>-logging
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: arn:aws:logs:${self:provider.region}:*:log-group:/aws/lambda/*:*:*
- Effect: "Allow"
Action:
- "s3:PutObject"
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- "Ref" : "ServerlessDeploymentBucket"
Roles:
- <%= appname %>-services-${self:custom.stage}-${self:provider.region}-lambdaRole
- <%= appname %>-services-${self:custom.stage}-accounting
lambdaInvocation:
Type: AWS::IAM::Policy
Properties:
PolicyName: <%= appname %>-invocation
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- lambda:InvokeFunction
- lambda:ListFunctions
Resource:
- "arn:aws:lambda:${self:custom.region}:*:function:<%= appname %>-services-${self:custom.stage}-*"
Roles:
- <%= appname %>-services-${self:custom.stage}-accounting
- <%= appname %>-services-${self:custom.stage}-${self:provider.region}-lambdaRole