Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go runtime does not allow type assertions to raw CFN resource types #3353

Closed
1 of 5 tasks
arnogeurts-sqills opened this issue Jan 31, 2022 · 1 comment · Fixed by #3354
Closed
1 of 5 tasks

Go runtime does not allow type assertions to raw CFN resource types #3353

arnogeurts-sqills opened this issue Jan 31, 2022 · 1 comment · Fixed by #3354
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1

Comments

@arnogeurts-sqills
Copy link
Contributor

arnogeurts-sqills commented Jan 31, 2022

🐛 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)
  • Go

General Information

  • JSII Version: v1.52.1

What is the problem?

func main() {
	app := awscdk.NewApp(nil)
	stack := awscdk.NewStack(app, jsii.String("dummy"), &awscdk.StackProps{})
	lambdaFunction := awslambda.NewFunction(stack, jsii.String("dummy-function"), &awslambda.FunctionProps{
		FunctionName: jsii.String("dummy-function"),
		Code:         awslambda.Code_FromBucket(awss3.Bucket_FromBucketName(stack, jsii.String("dummy-bucket"), jsii.String("bucket-name")), jsii.String("dummy-object-key"), nil),
		Handler:      jsii.String("main"),
		Runtime:      awslambda.Runtime_PROVIDED_AL2(),
	})
	_ = lambdaFunction.Node().DefaultChild().(awslambda.CfnFunction)
}

This code panics, because the default child is actually a jsiiProxy_IConstruct. However, I would expect this code to work, as it does in other languages like typescript:
https://stackoverflow.com/questions/59411734/add-conditions-to-resources-in-cdk

@arnogeurts-sqills arnogeurts-sqills added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 31, 2022
arnogeurts-sqills added a commit to sqills/jsii that referenced this issue Jan 31, 2022
@ryparker ryparker added the p1 label Jan 31, 2022
RomainMuller pushed a commit that referenced this issue Feb 3, 2022
…Proxy (#3354)

With this PR, the type that is instantiated as JSII Proxy is looked up from the type registry using the TypeFQDN in the ref. If that type is registered in the type registry AND that type is assignable to the targeted value type, than that type is used to instantiate the JSII proxy. 

Fixes #3353 and relates to #2819.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants