I'm submitting a ...
What is the current behavior?
If the current behavior is a :beetle:bug:beetle:: Please provide the steps to reproduce
Example code:
const domainZone = route53.HostedZone.fromHostedZoneId(this, 'domain-zone', hostedZoneId);
cdk synth
throws an error:
HostedZone.fromHostedZoneId doesn't support "zoneName"
fromHostedZoneId()
should return a valid IHosted颅Zone
object.
HostedZone
is needed, for instance, for LoadBalancedFargateServiceProps
(for the domainZone
property).
Please 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)
duplicate of https://github.com/aws/aws-cdk/issues/3558
using from_hostedzone_attributes() is the preferred method for fetching the hostedzone information
hey @realharry ,
As @rhboyd mentioned, this seems to be a duplicate. Please reopen if the behavior you're observing is unique and the direction provided in the related issue doesn't work for you.
@realharry for Hosted Zones there are 3 methods that accomplish very similar, but slightly different goals.
fromHostedZoneId(...)
and fromHostedZoneName(...)
will create a mock object with just the ZoneId or the ZoneName field present. These are useful if you need to supply a HostedZone object but you know that the resource that is accepting the HostedZone only needs access to one of those variables. This is done without having make an API call so it can be done entirely locally.
The third method is fromAttributes(...)
that will take the attributes and perform an API call to determine which exact HostedZone is deployed and updates its behavior accordingly.
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()
)
Is there any way to get the HostedZone if I only have the ID? I was using fromHostedZoneId and got the same error, but then I switched to using fromAttributes and now I need to provide the name in addition to the ID :(
Most helpful comment
@realharry for Hosted Zones there are 3 methods that accomplish very similar, but slightly different goals.
fromHostedZoneId(...)
andfromHostedZoneName(...)
will create a mock object with just the ZoneId or the ZoneName field present. These are useful if you need to supply a HostedZone object but you know that the resource that is accepting the HostedZone only needs access to one of those variables. This is done without having make an API call so it can be done entirely locally.The third method is
fromAttributes(...)
that will take the attributes and perform an API call to determine which exact HostedZone is deployed and updates its behavior accordingly.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 usedfromHostedZoneId()
)