From a653611dc8125b24e37dd757d4c66b0c8d14bf2a Mon Sep 17 00:00:00 2001 From: Christian Anton Date: Sat, 7 Aug 2021 13:03:14 +0200 Subject: [PATCH] azure: zone name as environment variable (#1433) --- cmd/zz_gen_cmd_dnshelp.go | 1 + docs/content/dns/zz_gen_azure.md | 1 + providers/dns/azure/azure.go | 5 +++++ providers/dns/azure/azure.toml | 1 + 4 files changed, 8 insertions(+) diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go index 9a80def6..cc672d04 100644 --- a/cmd/zz_gen_cmd_dnshelp.go +++ b/cmd/zz_gen_cmd_dnshelp.go @@ -261,6 +261,7 @@ func displayDNSHelp(name string) error { ew.writeln(` - "AZURE_POLLING_INTERVAL": Time between DNS propagation check`) ew.writeln(` - "AZURE_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) ew.writeln(` - "AZURE_TTL": The TTL of the TXT record used for the DNS challenge`) + ew.writeln(` - "AZURE_ZONE_NAME": Zone name to use inside Azure DNS service to add the TXT record in`) ew.writeln() ew.writeln(`More information: https://go-acme.github.io/lego/dns/azure`) diff --git a/docs/content/dns/zz_gen_azure.md b/docs/content/dns/zz_gen_azure.md index 4c4dcf7b..be0cd674 100644 --- a/docs/content/dns/zz_gen_azure.md +++ b/docs/content/dns/zz_gen_azure.md @@ -49,6 +49,7 @@ More information [here](/lego/dns/#configuration-and-credentials). | `AZURE_POLLING_INTERVAL` | Time between DNS propagation check | | `AZURE_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | | `AZURE_TTL` | The TTL of the TXT record used for the DNS challenge | +| `AZURE_ZONE_NAME` | Zone name to use inside Azure DNS service to add the TXT record in | The environment variable names can be suffixed by `_FILE` to reference a file instead of a value. More information [here](/lego/dns/#configuration-and-credentials). diff --git a/providers/dns/azure/azure.go b/providers/dns/azure/azure.go index 091b912f..7289592f 100644 --- a/providers/dns/azure/azure.go +++ b/providers/dns/azure/azure.go @@ -33,6 +33,7 @@ const ( EnvTenantID = envNamespace + "TENANT_ID" EnvClientID = envNamespace + "CLIENT_ID" EnvClientSecret = envNamespace + "CLIENT_SECRET" + EnvZoneName = envNamespace + "ZONE_NAME" EnvTTL = envNamespace + "TTL" EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" @@ -242,6 +243,10 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { // Checks that azure has a zone for this domain name. func (d *DNSProvider) getHostedZoneID(ctx context.Context, fqdn string) (string, error) { + if zone := env.GetOrFile(EnvZoneName); zone != "" { + return zone, nil + } + authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return "", err diff --git a/providers/dns/azure/azure.toml b/providers/dns/azure/azure.toml index c8336115..ae5ef422 100644 --- a/providers/dns/azure/azure.toml +++ b/providers/dns/azure/azure.toml @@ -20,6 +20,7 @@ Example = '''''' AZURE_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" AZURE_TTL = "The TTL of the TXT record used for the DNS challenge" AZURE_METADATA_ENDPOINT = "Metadata Service endpoint URL" + AZURE_ZONE_NAME = "Zone name to use inside Azure DNS service to add the TXT record in" [Links] API = "https://docs.microsoft.com/en-us/go/azure/"