-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline.yaml
228 lines (207 loc) · 6.59 KB
/
pipeline.yaml
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
---
AWSTemplateFormatVersion: 2010-09-09
Description: 'Template for CI/CD of AWS Lambda Benchmark'
Parameters:
AppName:
Type: String
Description: Name of the application.
MinLength: '1'
MaxLength: '80'
AllowedPattern: '[A-Za-z0-9-]+'
ConstraintDescription: Malformed input parameter. AppName must only contain upper and lower case letters, numbers, and -.
AppStackName:
Type: String
Description: Name of stack for the application.
MinLength: "1"
MaxLength: "80"
AllowedPattern: "[A-Za-z0-9-]+"
ConstraintDescription: Malformed input parameter. AppAppStackName must only contain upper and lower case letters, numbers, and -.
GitHubRepoName:
Type: String
Description: The GitHub repo name
GitHubRepoBranch:
Type: String
Description: The GitHub repo branch code pipelines should watch for changes on
Default: master
GitHubToken:
Type: String
Description: "Secret. OAuthToken with access to Repo. Long string of characters and digits. Go to https://github.com/settings/tokens"
NoEcho: true
GitHubUser:
Type: String
Description: GitHub UserName. This username must have access to the GitHubToken.
ArtifactS3Bucket:
Type: String
Description: The S3 bucket name to store the output artifacts
CodeBuildImage:
Type: String
Description: Image used for CodeBuild project.
Default: "aws/codebuild/standard:2.0"
CodePipelineRoleArn:
Type: String
Description: Role Arn the pipeline will use
CodeBuildRoleArn:
Type: String
Description: Role Arn for code build
LambdaDeployRoleArn:
Type: String
Description: Role Arn for deploying the lambdas
Resources:
codeBuildProject:
Description: Creating the AWS CodeBuild project
Type: AWS::CodeBuild::Project
Properties:
Name: !Sub ${AppName}-build
Description: CodeBuild project to build AWS Lambda benchmark
ServiceRole: !Ref CodeBuildRoleArn
Source:
Type: CODEPIPELINE
BuildSpec: build/ci/codebuild/buildspec.yml
Artifacts:
Type: CODEPIPELINE
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: !Ref CodeBuildImage
Type: LINUX_CONTAINER
PrivilegedMode: true
EnvironmentVariables:
- Name: S3_BUCKET
Value: !Ref ArtifactS3Bucket
TimeoutInMinutes: 10
Cache:
Type: S3
Location: !Sub ${ArtifactS3Bucket}/cache
dataLoadCodeBuild:
Type: AWS::CodeBuild::Project
Properties:
Name: !Sub ${AppName}-data-load
Description: CodeBuild project to load data for AWS Lambda benchmark
ServiceRole: !Ref CodeBuildRoleArn
Source:
Type: CODEPIPELINE
BuildSpec: build/ci/codebuild/dataLoadBuildspec.yml
Artifacts:
Type: CODEPIPELINE
Environment:
ComputeType: BUILD_GENERAL1_SMALL
Image: !Ref CodeBuildImage
Type: LINUX_CONTAINER
EnvironmentVariables:
- Name: APP_STACK
Value: !Ref AppStackName
TimeoutInMinutes: 5
Cache:
Type: S3
Location: !Sub ${ArtifactS3Bucket}/cache
pipeline:
Description: Creating a deployment pipeline for the project in AWS CodePipeline
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Sub ${AppName}-pipeline
RoleArn: !Ref CodePipelineRoleArn
Stages:
- Name: Source
Actions:
- Name: GitHub
InputArtifacts: []
ActionTypeId:
Category: Source
Provider: GitHub
Owner: ThirdParty
Version: "1"
OutputArtifacts:
- Name: !Sub "${AppName}-SourceArtifact"
Configuration:
Repo: !Ref GitHubRepoName
Branch: !Ref GitHubRepoBranch
OAuthToken: !Ref GitHubToken
Owner: !Ref GitHubUser
RunOrder: 1
- Name: Build
Actions:
- Name: Build
InputArtifacts:
- Name: !Sub "${AppName}-SourceArtifact"
ActionTypeId:
Category: Build
Provider: CodeBuild
Owner: AWS
Version: "1"
OutputArtifacts:
- Name: !Sub "${AppName}-BuildArtifact"
Configuration:
ProjectName: !Ref codeBuildProject
RunOrder: 1
- Name: Deploy
Actions:
- Name: CreateChangeset
InputArtifacts:
- Name: !Sub "${AppName}-BuildArtifact"
ActionTypeId:
Category: Deploy
Provider: CloudFormation
Owner: AWS
Version: "1"
OutputArtifacts: []
Configuration:
StackName: !Ref AppStackName
ActionMode: CHANGE_SET_REPLACE
RoleArn: !Ref LambdaDeployRoleArn
ChangeSetName: !Sub ${AppStackName}-changeset
Capabilities: CAPABILITY_NAMED_IAM
TemplatePath: !Sub "${AppName}-BuildArtifact::packaged.yml"
RunOrder: 1
- Name: ExecuteChangeset
InputArtifacts: []
ActionTypeId:
Category: Deploy
Provider: CloudFormation
Owner: AWS
Version: "1"
OutputArtifacts: []
Configuration:
StackName: !Ref AppStackName
ActionMode: CHANGE_SET_EXECUTE
RoleArn: !Ref LambdaDeployRoleArn
ChangeSetName: !Sub ${AppStackName}-changeset
RunOrder: 2
- Name: DataLoad
InputArtifacts:
- Name: !Sub "${AppName}-SourceArtifact"
ActionTypeId:
Category: Build
Provider: CodeBuild
Owner: AWS
Version: "1"
OutputArtifacts: []
Configuration:
ProjectName: !Ref dataLoadCodeBuild
RunOrder: 3
ArtifactStore:
Type: S3
Location: !Ref ArtifactS3Bucket
# CodeBuildProject:
# Description: Creating AWS CodeBuild project
# Type: AWS::CodeBuild::Project
# Properties:
# Artifacts:
# Type: CODEPIPELINE
# Description: !Sub "Building stage for ${AppName}."
# Environment:
# ComputeType: BUILD_GENERAL1_SMALL
# EnvironmentVariables:
# - Name: S3_BUCKET
# Value: !Ref ArtifactS3Bucket
# Image: !Ref CodeBuildImage
# Type: LINUX_CONTAINER
# Name: !Sub "${AppName}-build"
# ServiceRole: !Ref CodeBuildRole
# Source:
# Type: CODEPIPELINE
# Tags:
# - Key: app-name
# Value: !Ref AppName
# TimeoutInMinutes: 5
Outputs:
PipelineUrl:
Value: !Sub https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${pipeline}