Skip to content

Commit

Permalink
feat: add option to specify hosted zone ID (#261)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* fixup! feat: add option to specify hosted zone ID

---------

Signed-off-by: Andrew Dunham <[email protected]>
  • Loading branch information
andrew-d authored Jul 31, 2024
1 parent 7c03f51 commit 5032265
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 7 additions & 0 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5032265

Please sign in to comment.