-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-pipeline.yml
More file actions
94 lines (86 loc) · 2.78 KB
/
code-pipeline.yml
File metadata and controls
94 lines (86 loc) · 2.78 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Description: CloudFormation template to create an AWS CodePipeline
Parameters:
S3BucketName:
Description: S3 bucket to store the CloudFormation template and artifacts
Type: String
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref S3BucketName
Pipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
RoleArn: !GetAtt PipelineRole.Arn
ArtifactStore:
Type: S3
Location: !Ref S3Bucket
Stages:
- Name: Source
Actions:
- Name: SourceAction
ActionTypeId:
Category: Source
Owner: AWS
Provider: S3
Version: '1'
Configuration:
S3Bucket: !Ref S3Bucket
S3ObjectKey: cloudformation/ec2-template.yml
PollForSourceChanges: 'true'
OutputArtifacts:
- Name: SourceArtifact
RunOrder: 1
- Name: Deploy
Actions:
- Name: DeployAction
ActionTypeId:
Category: Deploy
Owner: AWS
Provider: CloudFormation
Version: '1'
Configuration:
ActionMode: CREATE_UPDATE
StackName: MyEC2Stack
Capabilities: CAPABILITY_NAMED_IAM
TemplatePath: SourceArtifact::cloudformation/ec2-template.yml
InputArtifacts:
- Name: SourceArtifact
RunOrder: 1
PipelineRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: codepipeline.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: CodePipelinePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:GetBucketVersioning
- s3:GetBucketLocation
- s3:ListBucket
- s3:PutObject
Resource: '*'
- Effect: Allow
Action:
- cloudformation:CreateStack
- cloudformation:UpdateStack
- cloudformation:DescribeStacks
- cloudformation:DeleteStack
Resource: '*'
Outputs:
PipelineName:
Description: Name of the created pipeline
Value: !Ref Pipeline
#How to deploy the stack
#aws cloudformation create-stack --stack-name MyPipelineStack --template-body file://pipeline-template.yml --parameters ParameterKey=S3BucketName,ParameterValue=<YourS3BucketName>