-
Notifications
You must be signed in to change notification settings - Fork 1
/
totem-pipeline.yml
258 lines (235 loc) · 7.57 KB
/
totem-pipeline.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Cloudformation template for automated orchestrator builds
Parameters:
CodePipelineBucketName:
Type: String
Description: S3 bucket used for uploading artifacts for CodePipeline
MinLength: 1
Default: totem-v3
GitBranch:
Type: String
Description: Git branch for source repository
MinLength: 1
Default: feature_git-workflow
GitOwner:
Type: String
Description: Owner of the github repository
Default: totem
GitRepo:
Type: String
Description: Orchestrator repository
Default: totem-v3-orchestrator
TestGitBranch:
Type: String
Description: Git branch of the test repository used for performing functional testing
MinLength: 1
Default: 'develop'
TestGitOwner:
Type: String
Description: Git Owner of the test repository used for functional testing
TestGitRepo:
Type: String
Description: Git Respository used for functional testing
GithubOauthToken:
Type: String
NoEcho: true
Description: Github Oauthtoken
MinLength: 1
GlobalStack:
Description: Name of totem global stack
Type: String
MinLength: 1
Default: 'totem-global'
OrchestratorEnvironmentStack:
Description: Name of the orchestrator environment stack
Type: String
MinLength: 1
Default: 'totem-orchestrator-environment'
Environment:
Description: Orchestrator environment (development, production, etc)
Type: String
MinLength: 1
Default: 'development'
App:
Description: Application name for orchestrator stack
Type: String
MinLength: 1
Default: 'totem-v3-orchestrator'
Client:
Description: Client for orchestrator stack
Type: String
MinLength: 1
Default: 'totem'
WebhookSecret:
Type: String
NoEcho: true
Description: Webhook secret to be used for configuring webhooks
MinLength: 1
ConfigServiceDeployStack:
Description: Name of config service deploy stack
Type: String
MinLength: 1
Default: 'totem-config-service-develop'
Resources:
CodeBuild:
Type: "AWS::CodeBuild::Project"
Properties:
Artifacts:
Type: CODEPIPELINE
Description: !Sub "Totem-v3 Orchestrator ${GitBranch} build"
Environment:
Type: LINUX_CONTAINER
Image: "aws/codebuild/eb-nodejs-6.10.0-amazonlinux-64:4.0.0"
ComputeType: BUILD_GENERAL1_SMALL
EnvironmentVariables:
- Name: TOTEM_BUCKET
Value:
Fn::ImportValue: !Sub "${GlobalStack}-TotemBucket"
- Name: APP
Value: !Ref App
- Name: CLIENT
Value: !Ref Client
- Name: ENVIRONMENT
Value: !Ref Environment
- Name: GIT_OWNER
Value: !Ref GitOwner
- Name: GIT_REPO
Value: !Ref GitRepo
- Name: GIT_BRANCH
Value: !Ref GitBranch
ServiceRole:
Fn::ImportValue: !Sub "${OrchestratorEnvironmentStack}-CodeBuildRole"
Source:
Type: CODEPIPELINE
BuildSpec: 'totem-buildspec.yml'
TimeoutInMinutes: 5
CodeBuildFunctionalTest:
Type: "AWS::CodeBuild::Project"
Properties:
Artifacts:
Type: CODEPIPELINE
Description: !Sub "Totem-v3 Orchestrator ${GitBranch} Functional Tests"
Environment:
Type: LINUX_CONTAINER
Image: "aws/codebuild/eb-nodejs-6.10.0-amazonlinux-64:4.0.0"
ComputeType: BUILD_GENERAL1_SMALL
EnvironmentVariables:
- Name: ENVIRONMENT
Value: !Ref Environment
- Name: TEST_OWNER
Value: !Ref TestGitOwner
- Name: TEST_REPO
Value: !Ref TestGitRepo
- Name: TEST_BRANCH
Value: !Ref TestGitBranch
- Name: GITHUB_TOKEN
Value: !Ref GithubOauthToken
- Name: AWS_REGION
Value: !Ref AWS::Region
- Name: ORCHESTRATOR_STACK
Value: !Sub "totem-orchestrator-${Environment}"
ServiceRole:
Fn::ImportValue: !Sub "${OrchestratorEnvironmentStack}-CodeBuildRole"
Source:
Type: CODEPIPELINE
BuildSpec: 'totem-buildspec-functional-test.yml'
TimeoutInMinutes: 5
CodePipeline:
Type: "AWS::CodePipeline::Pipeline"
DependsOn: CodeBuild
Properties:
ArtifactStore:
Type: S3
Location:
Fn::ImportValue: !Sub "${GlobalStack}-TotemBucket"
RoleArn:
Fn::ImportValue: !Sub "${OrchestratorEnvironmentStack}-CodePipelineRoleArn"
Stages:
- Name: Source
Actions:
- Name: source
ActionTypeId:
Category: Source
Owner: "ThirdParty"
Provider: "GitHub"
Version: 1
InputArtifacts: []
OutputArtifacts:
- Name: source
Configuration:
Owner: !Ref GitOwner
Repo: !Ref GitRepo
Branch: !Ref GitBranch
OAuthToken: !Ref GithubOauthToken
RunOrder: 1
- Name: Build
Actions:
- Name: CodeBuild
ActionTypeId:
Category: Build
Owner: "AWS"
Provider: "CodeBuild"
Version: 1
InputArtifacts:
- Name: source
OutputArtifacts:
- Name: build
Configuration:
ProjectName: !Ref CodeBuild
RunOrder: 1
- Name: Deploy
Actions:
- Name: SAMCreateChangeSet
ActionTypeId:
Category: Deploy
Owner: "AWS"
Provider: "CloudFormation"
Version: 1
InputArtifacts:
- Name: build
OutputArtifacts: []
Configuration:
ActionMode: CHANGE_SET_REPLACE
RoleArn:
Fn::ImportValue: !Sub "${OrchestratorEnvironmentStack}-LambdaDeployRoleArn"
StackName: !Sub "totem-orchestrator-${Environment}"
ChangeSetName: LamdaDeploy
TemplatePath: "build::totem-deploy-package.yml"
TemplateConfiguration: "build::template-config.json"
ParameterOverrides: !Sub |
{
"OrchestratorEnvironmentStack": "${OrchestratorEnvironmentStack}",
"GlobalStack": "${GlobalStack}",
"Environment": "${Environment}",
"GitBranch": "${GitBranch}",
"GithubOauthToken": "${GithubOauthToken}",
"WebhookSecret": "${WebhookSecret}",
"ConfigServiceDeployStack": "${ConfigServiceDeployStack}"
}
RunOrder: 1
- Name: SAMExecuteChangeSet
ActionTypeId:
Category: Deploy
Owner: "AWS"
Provider: "CloudFormation"
Version: 1
OutputArtifacts:
- Name: deploy
Configuration:
ActionMode: CHANGE_SET_EXECUTE
StackName: !Sub "totem-orchestrator-${Environment}"
ChangeSetName: LamdaDeploy
RunOrder: 2
- Name: FunctionalTest
Actions:
- Name: FunctionalTest
ActionTypeId:
Category: Test
Owner: "AWS"
Provider: "CodeBuild"
Version: 1
InputArtifacts:
- Name: source
OutputArtifacts: []
Configuration:
ProjectName: !Ref CodeBuildFunctionalTest
RunOrder: 1