-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Acessing the 'DistributionConfig' of the 'CfnDistribution_' throws an error #3284
Comments
Does this problem still exist with |
Still get the same error message in 1.1.0-devpreview |
Still get the same error in 1.4-devpreview |
Here is a samll repro:
But casting |
Still an issue with CDK 1.8 and JSII 0.17 sadly |
Still an issue with CDK 1.10.1 and JSII 0.18 sadly |
Alright - thanks for providing the repro code. We'll be having a look into the cause of this (hopefully) shortly, and will update the issue with our findings! |
Perfect, thank you @RomainMuller! These two are a bit related, at least the first, and might be beneficial to work on at the same time? |
Sorry it took me so long to come back. I'm looking into testing your reproduction against the current HEAD of aws/jsii, in hopes that the last kernel bug I fixed was the cause of this issue (I'm pretty optimistic!) |
No worries Just tried the latest CDK with JSII 0.19 with no change As a side note i get the following erro in my full code when using alias config and a ACM cert: |
Yeah the problem is our dependencies are currently not modeled currently and this allowed an incompatible JSII runtime to be picked up by your install. We are going to release a fixed version very soon. |
Just tested this again, no error this time, but the object returned cant be cast into a It throws this:
|
@RomainMuller is it possible to open this one up again, as it is still not fixed? |
I verified; just reproduced the above errors ( |
@njlynch Maybe unassign @RomainMuller so someone else can take a look? |
The issue is that |
@McDoit , Separate from the underlying issue, I wonder if we can help with anything with the construct library itself. What is it that CloudFront is missing such that you need to resort to these escape hatches and post-creation modifications? |
In order to allow converting an opaque object instance to an arbitrary (jsii-managed) interface type, the `UnsafeCase` operation may be used to instantiate a proxy while bypassing all type consistency checks. This is similar to using `as any` or `as T` in TypeScript, meaning that if the user performs a cast to an incorrect/unsupported type, undefined behavior follows. This would unblock certain specific use-case scenarios that static languages render difficult to enact, such as the one described in aws/aws-cdk#3284.
I've created aws/jsii#2192 to introduce an This would allow you to write something along the lines of: var dcp = (cfd.DistributionConfig as DeputyBase).UnsafeCast<CfnDistribution.DistributionConfigProperty>(); Effectively un-blocking your use-case (and other use-cases that involve property overrides with complex/composite properties). This might become more elegant in the future, as type unions are supported better (more info at aws/aws-cdk-rfcs#193). |
In order to allow converting an opaque object instance to an arbitrary (jsii-managed) interface type, the `UnsafeCase` operation may be used to instantiate a proxy while bypassing all type consistency checks. This is similar to using `as any` or `as T` in TypeScript, meaning that if the user performs a cast to an incorrect/unsupported type, undefined behavior follows. This would unblock certain specific use-case scenarios that static languages render difficult to enact, such as the one described in aws/aws-cdk#3284. In particular, this is the only way out until aws/aws-cdk-rfcs#193 is delivered, for dealing with instances of interfaces returned through a type union API. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Trying to remember it from over a year ago, but I think the reason was to modify some option and naming to convert our existing CF stacks to using the CDK instead. So deploying the same stack name (and resources) but wrap it in the CDK instead. Main issue there was that replacing the CF distributions as custom domains on them need to be unique, and we didn't want to deal with it manually or have downtime solving it. |
I tried it with CDK 1.70 and JSII 1.14, but I got the following error running the repro stack above: |
Hmmm. Thanks for reporting. I'll have a look into it. |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.
I'm submitting a ...
What is the current behavior?
If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce
Create a new
CloudFrontWebDistribution
,var cf = new CloudFrontWebDistribution
Access the underlying
CfnDistribution_
withvar cfd = cf.Node.FindChild("CFDistribution") as CfnDistribution_;
Acessing the
DistributionConfig
of theCfnDistribution_
throws an error:To be able to see the
DistributionConfig
of theCfnDistribution_
I was trying to work around other bugs in the
CloudFrontWebDistribution
by accessing theDistributionConfig
to modify and add it back as overridesPlease tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Stacktrace:
The text was updated successfully, but these errors were encountered: