forked from cloudtools/troposphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodePipeline.py
115 lines (107 loc) · 3.57 KB
/
CodePipeline.py
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
# Converted from CodePipeline example located at:
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-pipeline.html # noqa
from troposphere import Parameter, Ref, Template
from troposphere.codepipeline import (
Pipeline, Stages, Actions, ActionTypeId, OutputArtifacts, InputArtifacts,
ArtifactStore, DisableInboundStageTransitions)
t = Template()
CodePipelineServiceRole = t.add_parameter(Parameter(
"CodePipelineServiceRole",
Description="The CodePipelineServiceRole ARN to use",
Type="String"
))
ArtifactStoreS3Location = t.add_parameter(Parameter(
"ArtifactStoreS3Location",
Description="This should be an S3 bucket resource or bucket name",
Type="String"
))
pipeline = t.add_resource(Pipeline(
"AppPipeline",
RoleArn=Ref(CodePipelineServiceRole),
Stages=[
Stages(
Name="Source",
Actions=[
Actions(
Name="SourceAction",
ActionTypeId=ActionTypeId(
Category="Source",
Owner="AWS",
Version="1",
Provider="S3"
),
OutputArtifacts=[
OutputArtifacts(
Name="SourceOutput"
)
],
Configuration={
"S3Bucket": {"Ref": "SourceS3Bucket"},
"S3ObjectKey": {"Ref": "SourceS3ObjectKey"}
},
RunOrder="1"
)
]
),
Stages(
Name="Beta",
Actions=[
Actions(
Name="BetaAction",
InputArtifacts=[
InputArtifacts(
Name="SourceOutput"
)
],
ActionTypeId=ActionTypeId(
Category="Deploy",
Owner="AWS",
Version="1",
Provider="CodeDeploy"
),
Configuration={
"ApplicationName": {"Ref": "ApplicationName"},
"DeploymentGroupName": {"Ref": "DeploymentGroupName"}
},
RunOrder="1"
)
]
),
Stages(
Name="Release",
Actions=[
Actions(
Name="ReleaseAction",
InputArtifacts=[
InputArtifacts(
Name="SourceOutput"
)
],
ActionTypeId=ActionTypeId(
Category="Deploy",
Owner="AWS",
Version="1",
Provider="CodeDeploy"
),
Configuration={
"ApplicationName": {"Ref": "ApplicationName"},
"DeploymentGroupName": {"Ref": "DeploymentGroupName"}
},
RunOrder="1"
)
]
)
],
ArtifactStore=ArtifactStore(
Type="S3",
Location=Ref(ArtifactStoreS3Location)
),
DisableInboundStageTransitions=[
DisableInboundStageTransitions(
StageName="Release",
Reason="Disabling the transition until "
"integration tests are completed"
)
]
))
print(t.to_json())