-
Notifications
You must be signed in to change notification settings - Fork 0
/
codepipeline-cfn.yaml
100 lines (88 loc) · 2.83 KB
/
codepipeline-cfn.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
# aws cloudformation create-stack --stack-name codepipeline-cfn-us-east-1-demo --template-body file://codepipeline-cfn.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: >
This template creates a CodePipeline CloudFormation deployment.
Parameters:
DeploymentId:
Type: String
Description: A unique deployment identifier.
Default: demo
Service:
Type: String
Description: Name of the service or product that is associated with this stack.
Default: cfn-pipelines
Owner:
Type: String
Description: Email address of the person that created the stack.
# TemplateFileName:
# Type: String
# Description: CloudFormation Template File Name
# Default: web-server.yml
# TemplateConfigFileName:
# Type: String
# Description: CloudFormation Template Config File Name
# Default: config/vpc-19-config-us-east-1-cis.json
GitHubAccount:
Type: String
Description: GitHub Account
Default: jason4151
GitHubRepository:
Type: String
Description: GitHub Repository
Default: cfn
GitHubBranch:
Type: String
Description: GitHub Branch
Default: master
Resources:
### S3 ###
CfnS3Bucket:
Type: AWS::S3::Bucket
DeletionPolicy: Delete
Properties:
# BucketName: !Join ['', [ demo, -, !Ref 'Service', -, !Ref 'AWS::Region']]
### CodePipeline ###
WebServerCfnCodePipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Sub web-server-cfn-${DeploymentId}
RoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/ServiceRoleForCFN"
Stages:
- Name: Source
Actions:
- InputArtifacts: []
Name: Source
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: '1'
Provider: GitHub
OutputArtifacts:
- Name: SourceArtifact
Configuration:
Owner: !Ref 'GitHubAccount'
Repo: !Ref 'GitHubRepository'
Branch: !Ref 'GitHubBranch'
OAuthToken: !Join ['', ['{{resolve:secretsmanager:', GitHubApiKey, ':SecretString:GitHubApiKey}}' ]]
RunOrder: 1
- Name: Deploy
Actions:
- Name: Artifact
ActionTypeId:
Category: Deploy
Owner: AWS
Version: '1'
Provider: CloudFormation
InputArtifacts:
- Name: SourceArtifact
Configuration:
ActionMode: CREATE_UPDATE
Capabilities: CAPABILITY_NAMED_IAM
RoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/ServiceRoleForCFN"
StackName: !Ref 'AWS::StackName'
TemplatePath: !Sub "SourceArtifact::${TemplateFileName}"
TemplateConfiguration: !Sub "SourceArtifact::${TemplateConfigFileName}"
RunOrder: 2
ArtifactStore:
Type: S3
Location: !Ref 'CfnS3Bucket'