From 50322650109a2729eb670f3b1a36f1cf608a28a4 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Wed, 31 Jul 2024 13:43:18 -0400 Subject: [PATCH] feat: add option to specify hosted zone ID (#261) * feat: add option to specify hosted zone ID For cases where the automatic discovery doesn't work (e.g. when we're creating a certificate for "foo.bar.com", and have a zone for "bar.com" that we can create the challenge records in). Signed-off-by: Andrew Dunham * fixup! feat: add option to specify hosted zone ID --------- Signed-off-by: Andrew Dunham --- client.go | 4 ++++ provider.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/client.go b/client.go index fabfc86..8bb6936 100644 --- a/client.go +++ b/client.go @@ -201,6 +201,10 @@ func (p *Provider) getRecords(ctx context.Context, zoneID string, _ string) ([]l } func (p *Provider) getZoneID(ctx context.Context, zoneName string) (string, error) { + if p.HostedZoneID != "" { + return "/hostedzone/" + p.HostedZoneID, nil + } + getZoneInput := &r53.ListHostedZonesByNameInput{ DNSName: aws.String(zoneName), MaxItems: aws.Int32(1), diff --git a/provider.go b/provider.go index 1057713..e987a1f 100644 --- a/provider.go +++ b/provider.go @@ -58,6 +58,13 @@ type Provider struct { // WaitForPropagation if set to true, it will wait for the record to be // propagated before returning. WaitForPropagation bool `json:"wait_for_propagation,omitempty"` + + // HostedZoneID is the ID of the hosted zone to use. If not set, it will + // be discovered from the zone name. + // + // This option should contain only the ID; the "/hostedzone/" prefix + // will be added automatically. + HostedZoneID string `json:"hosted_zone_id,omitempty"` } // GetRecords lists all the records in the zone.