(Go aws-cdk-lib): (Unable to call OverrideLogicalId) #4534
Labels
bug
This issue is a bug.
documentation
This is a problem with documentation.
effort/medium
Medium work item – a couple days of effort
language/go
Regarding GoLang bindings
p2
Describe the bug
I am trying to set the logical id for a cdk resource so it doesn't get changed by the cdk, eg for a lambda I am doing:
lambda := awslambda.NewFunction(stack, jsii.String("MyId"),... awscdk.CfnResource(lambda.Node().DefaultChild()).OverrideLogicalId(jsii.String("MyId"))
This fails to compile with the error "cannot convert lambda.Node().DefaultChild() (value of type constructs.IConstruct) to type awscdk.CfnResource: constructs.IConstruct does not implement awscdk.CfnResource (missing method AddDeletionOverride)"
Expected Behavior
The code builds successfully and the logical id is overridden.
Current Behavior
The code fails to compile with error "cannot convert lambda.Node().DefaultChild() (value of type constructs.IConstruct) to type awscdk.CfnResource: constructs.IConstruct does not implement awscdk.CfnResource (missing method AddDeletionOverride)"
Reproduction Steps
Create lambda with the awslambda.NewFunction. Try to override the logical id with the code
awscdk.CfnResource(lambda.Node().DefaultChild()).OverrideLogicalId(jsii.String("MyId"))
Possible Solution
No response
Additional Information/Context
This isn't limited to lambdas but looks like a more general type problem. Possibly I am just doing something wrong but I can't see how to do a safe cast to call OverrideLogicalId.
CDK CLI Version
2.114.1 (build 02bbb1d)
Framework Version
No response
Node.js Version
v20.10.0
OS
MacOs 14.2
Language
Go
Language Version
1.21
Other information
No response
The text was updated successfully, but these errors were encountered: