aws/aws-cdk

core: add RemovalPolicyOptions parameter to L2 applyRemovalPolicy method

Open

#22,077 opened on Sep 16, 2022

View on GitHub
 (15 comments) (0 reactions) (0 assignees)TypeScript (10,710 stars) (3,530 forks)batch import
@aws-cdk/coreeffort/smallfeature-requestgood first issuep2

Description

Describe the feature

The applyRemovalPolicy method signature for L1 resources is: CfnResource.applyRemovalPolicy(policy: cdk.RemovalPolicy, options?: cdk.RemovalPolicyOptions): void

For L2 resources it is: Resource.applyRemovalPolicy(policy: cdk.RemovalPolicy): void

It would be nice to be able to pass the options in for L2 resources, and since the L2 method is just a wrapper for the L1 method, it should be trivial to do so.

Use Case

This is mainly a limitation when I need to set the applyToUpdateReplacePolicy option to false, which is actually quite often

Proposed Solution

Just add the options parameter here: https://github.com/aws/aws-cdk/blob/2e797b5a37c69561b42cbe07fe2144af41833e00/packages/%40aws-cdk/core/lib/resource.ts#L231

And pass it in here: https://github.com/aws/aws-cdk/blob/2e797b5a37c69561b42cbe07fe2144af41833e00/packages/%40aws-cdk/core/lib/resource.ts#L236

Other Information

Great first PR

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.41.0

Environment details (OS name and version, etc.)

Windows 10 Enterprise Version 10.0.19044

Contributor guide