-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
vpc-endpoint-service: impossible to change removal policy #30639
Comments
### Issue # (if applicable) Closes aws#30639. ### Reason for this change Cannot set removal policy on VpcEndpointService. defaultChild is not set. ### Description of changes Sets defaultChild of VpcEndpointService objects.
applyRemovalPolicy only works with CfnResource try this instead: const vpces = new ec2.VpcEndpointService(this, 'Id', {
vpcEndpointServiceLoadBalancers: [nlb],
});
(vpces.node.tryFindChild('Id') as CfnVPCEndpointService).applyRemovalPolicy(RemovalPolicy.RETAIN); Let me know if it works for you. |
Hi Pahud. I'm not especially interested in a workaround because I've already found one.
If you don't consider this a bug, feel free to resolve. Your suggestion seems a bit obtuse, though. How am I, a CDK user, meant to figure that out from the documentation? It also seems inconsistent with other established constructs. I can call |
Hi @slunk applyRemovalPolicy() is a method available in some L2 constructs, such as: BucketPolicy aws-cdk/packages/aws-cdk-lib/aws-s3/lib/bucket-policy.ts Lines 104 to 111 in efee07d
Redshift Table aws-cdk/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts Lines 292 to 294 in efee07d
If you look at its implementation, it essentially runs the applyRemovalPolicy() on The reason I am not considering it a bug is
We appreciate your PR to expose that method to the L2 surface. Unfortunately it was closed by the bot. This is a nice feature request though. Feel free to submit a new one for that and let me know if you need any help. You can find me on cdk.dev if you need any help. |
Fair enough, thanks for the explanation! I'll try to fix that request and resubmit when I get some time. |
Describe the bug
This snippet fails to compile:
Expected Behavior
Build succeeds, and the Cloudformation stack managing this vpc endpoint service has a resource whose removal policy is set to RETAIN.
Current Behavior
This error is emitted:
Reproduction Steps
Create a stack with a VpcEndpointService and set its removal policy.
Possible Solution
Set the defaultChild for this construct.
Additional Information/Context
No response
CDK CLI Version
2.144.0
Framework Version
No response
Node.js Version
v20.3.0
OS
linux
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: