aws / aws/aws-cdk

vpc-endpoint-service: impossible to change removal policy

Open
#30,639 4 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-iam effort/small feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

This snippet fails to compile:
```
const vpces = new VpcEndpointService(this, 'Id', {
vpcEndpointServiceLoadBalancers: [nlb],
});
vpces.applyRemovalPolicy(RemovalPolicy.RETAIN);
```

### 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:
```
Error: Cannot apply RemovalPolicy: no child or not a CfnResource. Apply the removal policy on the CfnResource directly.
```

### 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_

Contributor guide

Open the contributing guide

Research direction

Start at the VpcEndpointService construct and trace how applyRemovalPolicy resolves its default child, using the reproduction in the issue as the starting case. Done means the TypeScript snippet compiles and the generated CloudFormation resource for the VPC endpoint service has a RETAIN removal policy.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.