@Generated(value="jsii-pacmak/1.50.0 (build d1830a4)", date="2022-01-04T15:39:01.148Z") @Stability(value=Experimental) public enum RemovalPolicy extends Enum<RemovalPolicy>
The removal policy controls what happens to the resource if it stops being managed by CloudFormation. This can happen in one of three situations:
The Removal Policy applies to all above cases.
Many stateful resources in the AWS Construct Library will accept a
removalPolicy as a property, typically defaulting it to RETAIN.
If the AWS Construct Library resource does not accept a removalPolicy
argument, you can always configure it by using the escape hatch mechanism,
as shown in the following example:
Bucket bucket;
CfnResource cfnBucket = (CfnResource)bucket.node.findChild("Resource");
cfnBucket.applyRemovalPolicy(RemovalPolicy.DESTROY);
Example:
Vpc vpc = new Vpc(this, "Vpc");
DomainProps domainProps = DomainProps.builder()
.version(ElasticsearchVersion.V7_1)
.removalPolicy(RemovalPolicy.DESTROY)
.vpc(vpc)
// must be enabled since our VPC contains multiple private subnets.
.zoneAwareness(ZoneAwarenessConfig.builder()
.enabled(true)
.build())
.capacity(CapacityConfig.builder()
// must be an even number since the default az count is 2.
.dataNodes(2)
.build())
.build();
new Domain(this, "Domain", domainProps);
| Enum Constant and Description |
|---|
DESTROY
(experimental) This is the default removal policy.
|
RETAIN
(experimental) This uses the 'Retain' DeletionPolicy, which will cause the resource to be retained in the account, but orphaned from the stack.
|
SNAPSHOT
(experimental) This retention policy deletes the resource, but saves a snapshot of its data before deleting, so that it can be re-created later.
|
| Modifier and Type | Method and Description |
|---|---|
static RemovalPolicy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RemovalPolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
@Stability(value=Experimental) public static final RemovalPolicy DESTROY
It means that when the resource is removed from the app, it will be physically destroyed.
@Stability(value=Experimental) public static final RemovalPolicy RETAIN
@Stability(value=Experimental) public static final RemovalPolicy SNAPSHOT
Only available for some stateful resources, like databases, EFS volumes, etc.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html#aws-attribute-deletionpolicy-optionspublic static RemovalPolicy[] values()
for (RemovalPolicy c : RemovalPolicy.values()) System.out.println(c);
public static RemovalPolicy valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullCopyright © 2022. All rights reserved.