Skip to content

Commit ac9901a

Browse files
authored
feat(codepipeline): allow to disable stage transition (#19911)
Add a `transitionToEnabled` options to disable transition to a stage. A reason can be optionally specified with `transitionDisabledReason`. Closes #1649 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 47f6e50 commit ac9901a

File tree

8 files changed

+509
-3
lines changed

8 files changed

+509
-3
lines changed

packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const deployBucket = new s3.Bucket(stack, 'DeployBucket', {
2323
removalPolicy: cdk.RemovalPolicy.DESTROY,
2424
});
2525

26+
const otherDeployBucket = new s3.Bucket(stack, 'OtherDeployBucket', {
27+
removalPolicy: cdk.RemovalPolicy.DESTROY,
28+
});
29+
2630
new codepipeline.Pipeline(stack, 'Pipeline', {
2731
artifactBucket: bucket,
2832
stages: [
@@ -45,6 +49,17 @@ new codepipeline.Pipeline(stack, 'Pipeline', {
4549
}),
4650
],
4751
},
52+
{
53+
stageName: 'Disabled',
54+
transitionToEnabled: false,
55+
actions: [
56+
new cpactions.S3DeployAction({
57+
actionName: 'DisabledDeployAction',
58+
input: sourceOutput,
59+
bucket: otherDeployBucket,
60+
}),
61+
],
62+
},
4863
],
4964
});
5065

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-s3-deploy.integ.snapshot/aws-cdk-codepipeline-s3-deploy.template.json

+162-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"UpdateReplacePolicy": "Delete",
1616
"DeletionPolicy": "Delete"
1717
},
18+
"OtherDeployBucket7B0CCE57": {
19+
"Type": "AWS::S3::Bucket",
20+
"UpdateReplacePolicy": "Delete",
21+
"DeletionPolicy": "Delete"
22+
},
1823
"PipelineRoleD68726F7": {
1924
"Type": "AWS::IAM::Role",
2025
"Properties": {
@@ -89,6 +94,16 @@
8994
"Arn"
9095
]
9196
}
97+
},
98+
{
99+
"Action": "sts:AssumeRole",
100+
"Effect": "Allow",
101+
"Resource": {
102+
"Fn::GetAtt": [
103+
"PipelineDisabledDisabledDeployActionCodePipelineActionRole9CEF3915",
104+
"Arn"
105+
]
106+
}
92107
}
93108
],
94109
"Version": "2012-10-17"
@@ -176,14 +191,52 @@
176191
}
177192
],
178193
"Name": "Deploy"
194+
},
195+
{
196+
"Actions": [
197+
{
198+
"ActionTypeId": {
199+
"Category": "Deploy",
200+
"Owner": "AWS",
201+
"Provider": "S3",
202+
"Version": "1"
203+
},
204+
"Configuration": {
205+
"BucketName": {
206+
"Ref": "OtherDeployBucket7B0CCE57"
207+
},
208+
"Extract": "true"
209+
},
210+
"InputArtifacts": [
211+
{
212+
"Name": "SourceArtifact"
213+
}
214+
],
215+
"Name": "DisabledDeployAction",
216+
"RoleArn": {
217+
"Fn::GetAtt": [
218+
"PipelineDisabledDisabledDeployActionCodePipelineActionRole9CEF3915",
219+
"Arn"
220+
]
221+
},
222+
"RunOrder": 1
223+
}
224+
],
225+
"Name": "Disabled"
179226
}
180227
],
181228
"ArtifactStore": {
182229
"Location": {
183230
"Ref": "PipelineBucketB967BD35"
184231
},
185232
"Type": "S3"
186-
}
233+
},
234+
"DisableInboundStageTransitions": [
235+
{
236+
"Reason": "Transition disabled",
237+
"StageName": "Disabled"
238+
}
239+
]
187240
},
188241
"DependsOn": [
189242
"PipelineRoleDefaultPolicyC7A05455",
@@ -426,6 +479,114 @@
426479
}
427480
]
428481
}
482+
},
483+
"PipelineDisabledDisabledDeployActionCodePipelineActionRole9CEF3915": {
484+
"Type": "AWS::IAM::Role",
485+
"Properties": {
486+
"AssumeRolePolicyDocument": {
487+
"Statement": [
488+
{
489+
"Action": "sts:AssumeRole",
490+
"Effect": "Allow",
491+
"Principal": {
492+
"AWS": {
493+
"Fn::Join": [
494+
"",
495+
[
496+
"arn:",
497+
{
498+
"Ref": "AWS::Partition"
499+
},
500+
":iam::",
501+
{
502+
"Ref": "AWS::AccountId"
503+
},
504+
":root"
505+
]
506+
]
507+
}
508+
}
509+
}
510+
],
511+
"Version": "2012-10-17"
512+
}
513+
}
514+
},
515+
"PipelineDisabledDisabledDeployActionCodePipelineActionRoleDefaultPolicyB1AF629C": {
516+
"Type": "AWS::IAM::Policy",
517+
"Properties": {
518+
"PolicyDocument": {
519+
"Statement": [
520+
{
521+
"Action": [
522+
"s3:DeleteObject*",
523+
"s3:PutObject*",
524+
"s3:Abort*"
525+
],
526+
"Effect": "Allow",
527+
"Resource": [
528+
{
529+
"Fn::GetAtt": [
530+
"OtherDeployBucket7B0CCE57",
531+
"Arn"
532+
]
533+
},
534+
{
535+
"Fn::Join": [
536+
"",
537+
[
538+
{
539+
"Fn::GetAtt": [
540+
"OtherDeployBucket7B0CCE57",
541+
"Arn"
542+
]
543+
},
544+
"/*"
545+
]
546+
]
547+
}
548+
]
549+
},
550+
{
551+
"Action": [
552+
"s3:GetObject*",
553+
"s3:GetBucket*",
554+
"s3:List*"
555+
],
556+
"Effect": "Allow",
557+
"Resource": [
558+
{
559+
"Fn::GetAtt": [
560+
"PipelineBucketB967BD35",
561+
"Arn"
562+
]
563+
},
564+
{
565+
"Fn::Join": [
566+
"",
567+
[
568+
{
569+
"Fn::GetAtt": [
570+
"PipelineBucketB967BD35",
571+
"Arn"
572+
]
573+
},
574+
"/*"
575+
]
576+
]
577+
}
578+
]
579+
}
580+
],
581+
"Version": "2012-10-17"
582+
},
583+
"PolicyName": "PipelineDisabledDisabledDeployActionCodePipelineActionRoleDefaultPolicyB1AF629C",
584+
"Roles": [
585+
{
586+
"Ref": "PipelineDisabledDisabledDeployActionCodePipelineActionRole9CEF3915"
587+
}
588+
]
589+
}
429590
}
430591
}
431592
}

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-s3-deploy.integ.snapshot/manifest.json

+18
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
"data": "DeployBucket67E2C076"
2929
}
3030
],
31+
"/aws-cdk-codepipeline-s3-deploy/OtherDeployBucket/Resource": [
32+
{
33+
"type": "aws:cdk:logicalId",
34+
"data": "OtherDeployBucket7B0CCE57"
35+
}
36+
],
3137
"/aws-cdk-codepipeline-s3-deploy/Pipeline/Role/Resource": [
3238
{
3339
"type": "aws:cdk:logicalId",
@@ -69,6 +75,18 @@
6975
"type": "aws:cdk:logicalId",
7076
"data": "PipelineDeployDeployActionCodePipelineActionRoleDefaultPolicyE194961B"
7177
}
78+
],
79+
"/aws-cdk-codepipeline-s3-deploy/Pipeline/Disabled/DisabledDeployAction/CodePipelineActionRole/Resource": [
80+
{
81+
"type": "aws:cdk:logicalId",
82+
"data": "PipelineDisabledDisabledDeployActionCodePipelineActionRole9CEF3915"
83+
}
84+
],
85+
"/aws-cdk-codepipeline-s3-deploy/Pipeline/Disabled/DisabledDeployAction/CodePipelineActionRole/DefaultPolicy/Resource": [
86+
{
87+
"type": "aws:cdk:logicalId",
88+
"data": "PipelineDisabledDisabledDeployActionCodePipelineActionRoleDefaultPolicyB1AF629C"
89+
}
7290
]
7391
},
7492
"displayName": "aws-cdk-codepipeline-s3-deploy"

0 commit comments

Comments
 (0)