You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this while fixing #38262, and I am posting it as a tracking issue because the problem is not isolated to Memory.
Most of the bedrockagentcore L2 constructs create their Cfn resource plus at least one other child (usually a ServiceRole). Because of that, CDK never auto-assigns the Cfn resource as node.defaultChild, and calling applyRemovalPolicy() on the L2 throws:
CannotApplyRemovalPolicy: Cannot apply RemovalPolicy: no child or not a CfnResource.
This affects the following constructs (from a quick scan of packages/aws-cdk-lib/aws-bedrockagentcore/lib):
The fix is the same one-liner in each case: assign this.node.defaultChild = this.__resource (or whatever the Cfn field is) right after constructing it, matching how s3.Bucket and dynamodb.Table do it.
I have done Memory in #38313. I am happy to work through the rest if that is okay, or anyone else can grab individual ones. I thought a single tracking issue was better than opening twelve separate ones.
I noticed this while fixing #38262, and I am posting it as a tracking issue because the problem is not isolated to Memory.
Most of the bedrockagentcore L2 constructs create their Cfn resource plus at least one other child (usually a ServiceRole). Because of that, CDK never auto-assigns the Cfn resource as node.defaultChild, and calling applyRemovalPolicy() on the L2 throws:
CannotApplyRemovalPolicy: Cannot apply RemovalPolicy: no child or not a CfnResource.
This affects the following constructs (from a quick scan of packages/aws-cdk-lib/aws-bedrockagentcore/lib):
The fix is the same one-liner in each case: assign this.node.defaultChild = this.__resource (or whatever the Cfn field is) right after constructing it, matching how s3.Bucket and dynamodb.Table do it.
I have done Memory in #38313. I am happy to work through the rest if that is okay, or anyone else can grab individual ones. I thought a single tracking issue was better than opening twelve separate ones.
Progress
Memorydoes not set defaultChild, breaking applyRemovalPolicy #38282, fix(bedrockagentcore): set default child on Memory L2 so applyRemovalPolicy works #38313 closed in favor of it)I will work through the remaining ones as separate small PRs so each is easy to review.