This repository has been archived by the owner on Aug 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CodePipeline.yml
142 lines (142 loc) · 4.98 KB
/
CodePipeline.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
AWSTemplateFormatVersion: '2010-09-09'
Description: CodePipline Sample Template
Parameters:
ArtifactStoreBucket:
Description: S3 bucket to use for artifacts. Just bucket Name; not URL. IAM user should have access to the bucket.
Type: String
Default: codepipeline-us-east-1-XXXXXXXXXXX
PipelineName:
AllowedPattern: '^[a-zA-Z0-9-_]*$'
Description: 'Name to give the CodePipeline Project. For this sample, use the same name as your repository.'
MaxLength: '255'
MinLength: '2'
Type: String
GitHubUser:
Description: "GitHub UserName"
Type: String
Default: sarbajit
GitHubRepo:
Description: "GitHub Repo to pull from. Only the Name. not the URL"
Type: String
Default: reciter
GitHubBranch:
Description: "Branch to use from Repo. Only the Name. not the URL"
Type: String
Default: master
GitHubToken:
Description: "Secret. It might look something like 9b189a1654643522561f7b3ebd44a1531a4287af OAuthToken with access to Repo. Go to https://github.com/settings/tokens"
Type: String
NoEcho: true
DeployBeanstalkAppName:
Description: "ElasticBeanstalk application name to be used in the deploy process of pipeline"
Type: String
DeployBeanstalkEnvName:
Description: "ElasticBeanstalk environment name to be used in the deploy process of pipeline"
Type: String
CodePipelineServiceRole:
Description: This IAM role must have proper permissions to run the pipeline
Type: String
Default: arn:aws:iam::123456789012:role/AWS-CodePipeline-Service
AllowedPattern: arn:aws(-[\w]+)*:iam::[0-9]{12}:role/.*
BuildImage:
AllowedValues:
- 'aws/codebuild/standard:3.0'
Description: Docker Image to use in CodeBuild Project
Type: String
ProjectName:
AllowedPattern: '^[a-zA-Z0-9-_]*$'
Description: 'Name to give the CodeBuild Project. For this sample, use the same name as your repository.'
MaxLength: '255'
MinLength: '2'
Type: String
RepositoryUrl:
Description: "HTTPS Clone URL of the repository in GitHub. Example: 'https://github.com/owner/repo.git'"
Type: String
S3Bucket:
Description: S3 Bucket name for cloudformation template for codebuild
Type: String
S3Key:
Description: S3 Key for cloudformation template for codebuild
Type: String
Resources:
CodeBuildProject:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/${S3Bucket}/${S3Key}
Parameters:
BuildImage: !Ref BuildImage
ProjectName: !Ref ProjectName
RepositoryUrl: !Ref RepositoryUrl
AppPipeline:
Type: AWS::CodePipeline::Pipeline
DependsOn: CodeBuildProject
Properties:
Name: !Ref PipelineName
RoleArn: !Ref CodePipelineServiceRole
ArtifactStore:
Type: S3
Location: !Ref ArtifactStoreBucket
Stages:
-
Name: Source
Actions:
-
Name: ApplicationSource
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: '1'
Provider: GitHub
Configuration:
Owner: !Ref GitHubUser
Repo: !Ref GitHubRepo
Branch: !Ref GitHubBranch
OAuthToken: !Ref GitHubToken
OutputArtifacts:
-
Name: source-output-artifact
RunOrder: 1
-
Name: Build
Actions:
-
Name: CodeBuild
InputArtifacts:
-
Name: source-output-artifact
ActionTypeId:
Category: Build
Owner: AWS
Version: '1'
Provider: CodeBuild
Configuration:
ProjectName: !Ref ProjectName
OutputArtifacts:
-
Name: build-output-artifact
RunOrder: 1
-
Name: Deploy
Actions:
-
Name: Deployment
InputArtifacts:
-
Name: build-output-artifact
ActionTypeId:
Category: Deploy
Owner: AWS
Version: '1'
Provider: ElasticBeanstalk
Configuration:
ApplicationName: !Ref DeployBeanstalkAppName
EnvironmentName: !Ref DeployBeanstalkEnvName
RunOrder: 1
RestartExecutionOnUpdate: false
Outputs:
CodeBuildName:
Description: CodePipeline Name
Value:
Ref: AppPipeline
Export:
Name: !Sub ${AWS::StackName}-AppPipelineName