aws / aws/jsii

(Go aws-cdk-lib): (Unable to call OverrideLogicalId)

Open
#4,534 3 comments 0 reactions 0 assignees View on GitHub
bug documentation effort/medium language/go p2
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

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

Contributor guide

Open the contributing guide

Research direction

Start by tracing the Go bindings for awscdk.CfnResource and the constructs.IConstruct returned by lambda.Node().DefaultChild(). Check how OverrideLogicalId is exposed and how the missing AddDeletionOverride method affects the conversion. Done means the reported Go example compiles and overrides the logical ID, with coverage for the general type problem beyond lambdas.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, go, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.