-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathserverless.yml
178 lines (160 loc) · 5.72 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
service: bamboo-on-teams-${self:custom.version}
provider:
name: aws
runtime: nodejs12.x
versionFunctions: false
memorySize: 512
region: ap-southeast-2
stage: ${opt:stage, 'local'}
timeout: 30
deploymentBucket:
name: ${ssm:/bamboo-on-teams/deploymentBucket}
serverSideEncryption: AES256
# VPC configuration for functions to access the private Bamboo API which can be removed if Bamboo is public available.
vpc:
securityGroupIds:
- ${ssm:/bamboo-on-teams/securityGroupId}
subnetIds:
- ${ssm:/bamboo-on-teams/subnetId}
iamRoleStatements:
- Effect: "Allow"
Action:
- ssm:GetParameter
Resource:
- arn:aws:ssm:${self:provider.region}:${ssm:/bamboo-on-teams/accountId}:parameter/bamboo-on-teams/*
- Effect: Allow
Action:
- states:StartExecution
Resource:
- ${self:custom.aws.stepFunction.statusChecker.arn}
- ${self:custom.aws.stepFunction.buildAndDeployer.arn}
- ${self:custom.aws.stepFunction.batcher.arn}
- ${self:custom.aws.stepFunction.releaser.arn}
apiGateway:
restApiId: !Ref ApiGatewayRestApi
restApiRootResourceId: !Ref bambooV1PathResource
environment:
REGION: ap-southeast-2
BATH_PATH: bamboo/v1${self:custom.api.urls.prefix}
STATUS_CHECKER_ARN: ${self:custom.aws.stepFunction.statusChecker.arn}
BUILD_AND_DEPLOYER_ARN: ${self:custom.aws.stepFunction.buildAndDeployer.arn}
BATCHER_ARN: ${self:custom.aws.stepFunction.batcher.arn}
RELEASER_ARN: ${self:custom.aws.stepFunction.releaser.arn}
STEP_FUNCTIONS_ENDPOINT: https://states.ap-southeast-2.amazonaws.com
TZ: Pacific/Auckland
APPLICATION_CONFIG: ${ssm:/bamboo-on-teams/applicationConfig~true}
package:
excludeDevDependencies: false
patterns:
- '!node_modules/**'
resources:
Resources:
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: ${self:custom.aws.gateway.name}
EndpointConfiguration:
Types:
- REGIONAL
Policy:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal: "*"
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
BasePathResourse:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref ApiGatewayRestApi
ParentId: !GetAtt
- ApiGatewayRestApi
- RootResourceId
PathPart: bamboo
bambooV1PathResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref ApiGatewayRestApi
ParentId: !Ref BasePathResourse
PathPart: v1
functions:
api:
name: ${self:service}
events:
- http:
private: false
path: ${self:custom.api.urls.command}
method: post
cors: true
handler: dist/functions/api/router.router
# release operation lambda
notifyReleaseFunc:
name: ${self:service}-${self:provider.stage}-notifyRelease
handler: dist/functions/api/handlers/batcher.notifyRelease
# batch operation lambdas
executeSingleFunc:
name: ${self:service}-${self:provider.stage}-executeSingle
handler: dist/functions/api/handlers/batcher.executeSingle
checkSingleFunc:
name: ${self:service}-${self:provider.stage}-checkSingle
handler: dist/functions/api/handlers/batcher.checkSingle
notifySingleFunc:
name: ${self:service}-${self:provider.stage}-notifySingle
handler: dist/functions/api/handlers/batcher.notifySingle
notifyAllFunc:
name: ${self:service}-${self:provider.stage}-notifyAll
handler: dist/functions/api/handlers/batcher.notifyAll
# non batch operations lambdas
checkStatusFunc:
name: ${self:service}-${self:provider.stage}-statusChecker
handler: dist/functions/api/handlers/statusChecker.checkJobStatus
notifyStatusFunc:
name: ${self:service}-${self:provider.stage}-statusNotifier
handler: dist/functions/api/handlers/statusChecker.notifyJobStatus
plugins:
- serverless-offline
- serverless-offline-ssm
- serverless-step-functions
- serverless-plugin-common-excludes
- serverless-plugin-include-dependencies
- serverless-prune-plugin
stepFunctions:
stateMachines: ${file(resources/stateMachines.yml)}
custom:
version: v1
aws:
gateway:
name: ${self:service}
stepFunction:
releaser:
name: ${self:service}-releaser-${self:provider.stage}
arn: arn:aws:states:${self:provider.region}:${ssm:/bamboo-on-teams/accountId}:stateMachine:${self:custom.aws.stepFunction.releaser.name}
batcher:
name: ${self:service}-batcher-${self:provider.stage}
arn: arn:aws:states:${self:provider.region}:${ssm:/bamboo-on-teams/accountId}:stateMachine:${self:custom.aws.stepFunction.batcher.name}
buildAndDeployer:
name: ${self:service}-build-and-deployer-${self:provider.stage}
arn: arn:aws:states:${self:provider.region}:${ssm:/bamboo-on-teams/accountId}:stateMachine:${self:custom.aws.stepFunction.buildAndDeployer.name}
statusChecker:
name: ${self:service}-status-checker-${self:provider.stage}
arn: arn:aws:states:${self:provider.region}:${ssm:/bamboo-on-teams/accountId}:stateMachine:${self:custom.aws.stepFunction.statusChecker.name}
prune:
automatic: true
number: 3
serverless-offline:
noPrependStageInUrl: true
serverless-offline-ssm:
stages:
- bamboo
- local
ssm:
"/bamboo-on-teams/accountId": placeholder
"/bamboo-on-teams/deploymentBucket": placeholder
"/bamboo-on-teams/securityGroupId": placeholder
"/bamboo-on-teams/subnetId": placeholder
"/bamboo-on-teams/applicationConfig": placeholder
api:
urls:
prefix: /bamboo-on-teams/v1
command: ${self:custom.api.urls.prefix}/command