Skip to content

Commit d61bd2c

Browse files
authored
fix(core): UpdateReplacePolicy mirrors DeletionPolicy (#3217)
When setting the DeletionPolicy, the UpdateReplacePolicy should also be set. There's the same implication of data loss for one and the other. Fixes #2901.
1 parent 7d020f1 commit d61bd2c

File tree

89 files changed

+388
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+388
-165
lines changed

packages/@aws-cdk/app-delivery/test/integ.cicd.expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"Resources": {
33
"ArtifactBucket7410C9EF": {
44
"Type": "AWS::S3::Bucket",
5-
"DeletionPolicy": "Delete"
5+
"DeletionPolicy": "Delete",
6+
"UpdateReplacePolicy": "Delete"
67
},
78
"CodePipelineRoleB3A660B4": {
89
"Type": "AWS::IAM::Role",

packages/@aws-cdk/aws-apigateway/lib/deployment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CfnDeletionPolicy, Construct, Lazy, Resource, Stack } from '@aws-cdk/core';
1+
import { Construct, Lazy, RemovalPolicy, Resource, Stack } from '@aws-cdk/core';
22
import crypto = require('crypto');
33
import { CfnDeployment, CfnDeploymentProps } from './apigateway.generated';
44
import { IRestApi } from './restapi';
@@ -72,7 +72,7 @@ export class Deployment extends Resource {
7272
});
7373

7474
if (props.retainDeployments) {
75-
this.resource.cfnOptions.deletionPolicy = CfnDeletionPolicy.RETAIN;
75+
this.resource.applyRemovalPolicy(RemovalPolicy.RETAIN);
7676
}
7777

7878
this.api = props.api;

packages/@aws-cdk/aws-apigateway/test/integ.restapi.expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"myapiv1toysPUT59AFBBC2",
2727
"myapiv1toysA55FCBC4"
2828
],
29-
"DeletionPolicy": "Retain"
29+
"DeletionPolicy": "Retain",
30+
"UpdateReplacePolicy": "Retain"
3031
},
3132
"myapiDeploymentStagebeta96434BEB": {
3233
"Type": "AWS::ApiGateway::Stage",

packages/@aws-cdk/aws-apigateway/test/test.deployment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export = {
9999
Ref: "apiC8550315"
100100
}
101101
},
102-
DeletionPolicy: "Retain"
102+
DeletionPolicy: "Retain",
103+
UpdateReplacePolicy: "Retain"
103104
}
104105
}
105106
});

packages/@aws-cdk/aws-cloudformation/test/integ.trivial-lambda-resource.expected.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"Message": "CustomResource says hello"
1313
},
14-
"DeletionPolicy": "Delete"
14+
"DeletionPolicy": "Delete",
15+
"UpdateReplacePolicy": "Delete"
1516
},
1617
"SingletonLambdaf7d4f7304ee111e89c2dfa7ae01bbebcServiceRoleFE9ABB04": {
1718
"Type": "AWS::IAM::Role",
@@ -86,4 +87,4 @@
8687
}
8788
}
8889
}
89-
}
90+
}

packages/@aws-cdk/aws-cloudformation/test/test.resource.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export = testCase({
5050
// THEN
5151
expect(stack).to(haveResource('AWS::CloudFormation::CustomResource', {
5252
DeletionPolicy: 'Retain',
53+
UpdateReplacePolicy: 'Retain',
5354
}, ResourcePart.CompleteDefinition));
5455

5556
test.done();
@@ -112,6 +113,7 @@ export = testCase({
112113
"Custom1D319B237": {
113114
"Type": "AWS::CloudFormation::CustomResource",
114115
"DeletionPolicy": "Delete",
116+
"UpdateReplacePolicy": "Delete",
115117
"Properties": {
116118
"ServiceToken": {
117119
"Fn::GetAtt": [
@@ -124,6 +126,7 @@ export = testCase({
124126
"Custom2DD5FB44D": {
125127
"Type": "AWS::CloudFormation::CustomResource",
126128
"DeletionPolicy": "Delete",
129+
"UpdateReplacePolicy": "Delete",
127130
"Properties": {
128131
"ServiceToken": {
129132
"Fn::GetAtt": [

packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-bucket-logging.expected.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Resources": {
33
"Bucket83908E77": {
44
"DeletionPolicy": "Delete",
5+
"UpdateReplacePolicy": "Delete",
56
"Type": "AWS::S3::Bucket"
67
},
78
"AnAmazingWebsiteProbablyCFDistribution47E3983B": {
@@ -72,7 +73,8 @@
7273
},
7374
"AnAmazingWebsiteProbably2LoggingBucket222F7CE9": {
7475
"Type": "AWS::S3::Bucket",
75-
"DeletionPolicy": "Retain"
76+
"DeletionPolicy": "Retain",
77+
"UpdateReplacePolicy": "Retain"
7678
},
7779
"AnAmazingWebsiteProbably2CFDistribution7C1CCD12": {
7880
"Type": "AWS::CloudFront::Distribution",
@@ -140,4 +142,4 @@
140142
}
141143
}
142144
}
143-
}
145+
}

packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-ipv6-disabled.expected.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Resources": {
33
"Bucket83908E77": {
44
"DeletionPolicy": "Delete",
5+
"UpdateReplacePolicy": "Delete",
56
"Type": "AWS::S3::Bucket"
67
},
78
"MyDistributionCFDistributionDE147309": {
@@ -51,4 +52,4 @@
5152
}
5253
}
5354
}
54-
}
55+
}

packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.expected.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Resources": {
33
"Bucket83908E77": {
44
"DeletionPolicy": "Delete",
5+
"UpdateReplacePolicy": "Delete",
56
"Type": "AWS::S3::Bucket"
67
},
78
"LambdaServiceRoleA8ED4D3B": {

packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-s3.expected.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"Resources": {
33
"Bucket83908E77": {
44
"DeletionPolicy": "Delete",
5+
"UpdateReplacePolicy": "Delete",
56
"Type": "AWS::S3::Bucket"
67
},
78
"BucketPolicyE9A3008A": {

0 commit comments

Comments
 (0)