This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsetup-block-production-resources-stack.yml
140 lines (134 loc) · 5.23 KB
/
setup-block-production-resources-stack.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
AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS Cloudformation template to help create synthetic tests demo resources.'
Parameters:
DemoResourcesCodeCommitRepo:
Description: AWS CodeCommit repository name which contains the demo resources
Type: String
Default: "aws-codepipeline-block-production"
DemoResourcesCodeCommitRepoBranch:
Description: AWS CodeCommit repository branch
Type: String
Default: "master"
Resources:
ArtifactStoreBucket:
Type: AWS::S3::Bucket
Pipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
ArtifactStore:
Location: !Ref 'ArtifactStoreBucket'
Type: S3
Name: "SetupBlockProductionDemoResources-Pipeline"
RoleArn: !GetAtt [PipelineRole, Arn]
Stages:
- Name: Source
Actions:
- Name: DemoResourcesSource
ActionTypeId:
Category: Source
Owner: AWS
Provider: CodeCommit
Version: '1'
Configuration:
RepositoryName: !Ref DemoResourcesCodeCommitRepo
BranchName: !Ref DemoResourcesCodeCommitRepoBranch
OutputArtifacts:
- Name: DemoArtifacts
RunOrder: '1'
- Name: CloudformationDeploy
Actions:
- Name: CreateDemoResources
ActionTypeId:
Category: Deploy
Owner: AWS
Provider: CloudFormation
Version: '1'
InputArtifacts:
- Name: DemoArtifacts
Configuration:
ActionMode: CREATE_UPDATE
RoleArn: !GetAtt [CloudFormationRole, Arn]
StackName: BlockProductionDemoResources
TemplatePath: DemoArtifacts::block-production-demo-resources.yml
TemplateConfiguration: DemoArtifacts::block-production-demo-resources-parameters.json
ParameterOverrides: |
{
"DemoResourcesS3BucketName" : { "Fn::GetArtifactAtt" : ["DemoArtifacts", "BucketName"]},
"DemoResourcesS3ObjectKey" : { "Fn::GetArtifactAtt" : ["DemoArtifacts", "ObjectKey"]}
}
Capabilities: CAPABILITY_IAM
RunOrder: '1'
CloudFormationRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: ['sts:AssumeRole']
Effect: Allow
Principal:
Service: [cloudformation.amazonaws.com]
Version: '2012-10-17'
Path: /
Policies:
- PolicyName: CloudFormationRole
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action: '*'
Effect: Allow
Resource: '*'
PipelineRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: ['sts:AssumeRole']
Effect: Allow
Principal:
Service: [codepipeline.amazonaws.com]
Version: '2012-10-17'
Path: /
Policies:
- PolicyName: CodePipelineAccess
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "s3:GetObject"
- "s3:PutObject"
Resource:
- "Fn::Join": ["", ["arn:aws:s3:::", {"Ref": "ArtifactStoreBucket"}, "/*" ]]
- Effect: "Allow"
Action:
- "s3:ListBucket"
Resource:
- "Fn::Join": ["", ["arn:aws:s3:::", {"Ref": "ArtifactStoreBucket"}]]
- Effect: Allow
Action:
- 'cloudformation:CreateStack'
- 'cloudformation:DescribeStacks'
- 'cloudformation:DeleteStack'
- 'cloudformation:UpdateStack'
- 'cloudformation:CreateChangeSet'
- 'cloudformation:ExecuteChangeSet'
- 'cloudformation:DeleteChangeSet'
- 'cloudformation:DescribeChangeSet'
- 'cloudformation:SetStackPolicy'
Resource:
- "Fn::Join": ["", ["arn:aws:cloudformation:", { "Ref" : "AWS::Region" }, ":", { "Ref" : "AWS::AccountId" }, ":stack/", "BlockProductionDemoResources"]]
- "Fn::Join": ["", ["arn:aws:cloudformation:", { "Ref" : "AWS::Region" }, ":", { "Ref" : "AWS::AccountId" }, ":stack/", "BlockProductionDemoResources/*"]]
- Effect: Allow
Action:
- 'iam:PassRole'
Resource:
- !GetAtt [CloudFormationRole, Arn]
- Effect: Allow
Action:
- "codecommit:GetBranch"
- "codecommit:GetCommit"
- "codecommit:UploadArchive"
- "codecommit:GetUploadArchiveStatus"
- "codecommit:CancelUploadArchive"
Resource:
- "Fn::Join": ["", ["arn:aws:codecommit:", { "Ref" : "AWS::Region" }, ":", { "Ref" : "AWS::AccountId" }, ":", {"Ref" : "DemoResourcesCodeCommitRepo"}]]