-
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
from_hosted_zone_id fails when the object is referenced to retrieve a HZ name. #3558
Comments
Yup, hit the same issue as well, using the "from_hosted_zone_attributes" for now. |
This should probably be reclassified as a UX Issue. It's not clear to new developers when to use from_id() from_name() or from_attributes() for most resources. I don't think this is an actual bug, it just leads to people using the wrong methods. |
I think you might want to use Closing this issue, please reopen if you feel this was closed in error. |
I think this should be made into a docs issue. This exact issue (from_id() vs from_name() vs lookup()) has been brought up at least 3 times in the past two weeks. Enough people are misled by it that the docs could probably be made a bit clearer. |
I don't think this outcome is satisfactory (closing the issue as "wont-fix"). The use case is that users want to be able to get the domain of a HostedZone from it's zone ID (either directly, or for passing to some other CDK function), and there is no solution for this. The root issue here is not documentation (although that's certainly contributing to confusion). Rather, the problem is that some users expect the Further, it is a reasonable expectation that if an object implements an interface (such as At the very least, we should make a clearer distinction between methods that perform a contextual lookup, and methods that create a partial mock (eg. have a dedicated mock class and do something like |
I would agree with @garyd203 here in that throwing an exception on an interface member is a violation of the Liskov Substitution Principle. (See the part about throwing a I think the solution here is to adjust the model, something like adding a deprecation warning where appropriate and then changing Since I would consider the LSP to be fairly critical to design of a tool like CDK, I would ask that the maintainers reopen this issue. |
I ran into this just now and the error one is getting is very misleading as well as the implementation of the |
I, too, think this is definitely a bug. This will cause the same error:
I have obtained an |
I just stumbled upon this, too. Based on the CDK docs I expect |
Just ran into this issue, fromHostedZoneId allegedly returns an IPublicHostedZone, but addDelegation can't use it:
|
I also just ran into this issue while trying to use fromPublicHostedZoneId to create an ARecord. |
Also just ran into this when wanting to define a I should be able to retrieve an existing r53 hosted zone to use here |
Same experience when trying to create a record in a hostedzone when I only have the ID and use fromHostedZoneId. |
gh-293 As discussed in these issues: aws/aws-cdk#3663 aws/aws-cdk#3558 you can't get an acutal Hosted Zone just with the ID. What you wind up with when you query by ID, as I was doing prior to this commit, is some kind of mock object that sounds like it helps with local synth, but not with actually deploying resources. AWS does not seem like it will fix this unfortunately. This change tries to fetch by both name and ID. I was getting errors like: Error: HostedZone.fromHostedZoneId doesn't support "zoneName" https://github.com/douglasnaphas/madliberation/runs/2062714182?check_suite_focus=true I believe because the hosted zone I fetched was not a real hosted zone. The docs for fromHostedZoneId (https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-route53.HostedZone.html#static-fromwbrhostedwbrzonewbridscope-id-hostedzoneid), which I was using, do say: > Hosted zone name becomes unavailable through this query. A CDK maintainer adds the shocking statement: > The first two methods create use different Classes of IHostedZone that > throw an error if you use the wrong parameter (e.g. calling getName() > when you used fromHostedZoneId()) aws/aws-cdk#3663 (comment) It is very disappointing that the CDK maintainers decided to provide an implementation of an interface that throws an error when you try to get its name.
I was bitten by that in cdk 1.94.1 when trying to create a record in a hosted zone retrieved using The Unfortunately that is not mentioned in |
Why would anyone half-sane prefer essentially relying on a search instead of a get-by-id for something as sensitive as DNS zones? Especially when HostedZoneProviderProps' Wat |
I was hit with this bug today as well. All I want to do is to call |
I'm submitting a ...
What is the current behavior?
If the current behavior is a πͺ²bugπͺ²: Please provide the steps to reproduce
I have a hosted zone that is created when I purchase a route53 domain. that domain has a Public Hosted Zone that AWS creates for me. I want to use this hosted zone to validate ACM Certificates through DNS. In order to do this in Python CDK, I am trying to leverage the
aws_route53.HostedZone.from_hosted_zone_id
method.My first attempt looks like this:
which results in an error stating:
jsii.errors.JSIIError: HostedZone.fromHostedZoneId doesn't support "zoneName"
and points to the cause at the line
domain_name=props.domain_name
If I change the method to this it works:
but this requires me to pass in the hosted zone name, hosted zone id, and the desired domain name (subdomain of hosted zone), when I should be able to do what I need with just the Hosted Zone Id and desired domain name since I assume HZ Ids are region unique within an account.
What is the expected behavior (or behavior of feature suggested)?
from_hosted_zone_id should create a IHostedZone that can be used by resources that need the Hosted Zone name as well
What is the motivation / use case for changing the behavior or adding this feature?
better UX? Who doesn't love that?
Please tell us about your environment:
Other information
My "full" Python code.
The text was updated successfully, but these errors were encountered: