CDK NestedStack: Accessing a nested stack resource in a stack resolves to Amazon.JSII.Runtime.Deputy.AnonymousObject and cannot be casted to CfnStack
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
I have use case that I need to add parameters being provided to a nested stack that is created by an AWS provided EKS construct (in this case the nested stacks containing the Kubectl and resource provider lambda functions). I can find the resources in the node tree, but they cannot be casted to a `CfnStack`, they are of type `Amazon.JSII.Runtime.Deputy.AnonymousObject` and I cannot access the `parameters` property of the stack. This results in having to manipulate the rendered CloudFormation template to achieve the desired outcome.
### Expected Behavior
Be able to access a nested stack resource and cast it to a `CfnStack`.
### Current Behavior
The only available type is `Amazon.JSII.Runtime.Deputy.AnonymousObject`.
### Reproduction Steps
```csharp
FixUpResourceProvider("@aws-cdk--aws-eks.ClusterResourceProvider");
FixUpResourceProvider("@aws-cdk--aws-eks.KubectlProvider");
private void FixUpResourceProvider(string name)
{
IConstruct resourceProviderNestedStack = this.Node.TryFindChild(name);
// Add the parameters to the actual nested stack so it can receive them
if (resourceProviderNestedStack != null)
{
NestedStack nestedStack = resourceProviderNestedStack as NestedStack;
var nestedStackResource = nestedStack.NestedStackResource as CfnStack;
nestedStackResource.Parameters.GetType() == typeof(Amazon.JSII.Runtime.Deputy.AnonymousObject)
}
}
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.138.0
### Framework Version
_No response_
### Node.js Version
v20.9.0
### OS
darwin
### Language
.NET
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Reproduce the issue with the C# snippet against AWS CDK 2.138.0, focusing on NestedStack.NestedStackResource, CfnStack, and the JSII AnonymousObject value. Trace how the nested stack resource is exposed to .NET and determine what is needed for it to be castable and for Parameters to be accessible. Done means the reproduction can access the nested stack as a CfnStack without manipulating the rendered template.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, csharp, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100