terraform-provider-dns icon indicating copy to clipboard operation
terraform-provider-dns copied to clipboard

Issues with environmental variables DNS_UPDATE_USERNAME and DNS_UPDATE_PASSWORD

Open alexpekurovsky opened this issue 3 years ago • 5 comments

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

terraform -v Terraform v0.12.30

  • provider.aws v2.70.0
  • provider.dns v3.1.0
  • provider.template v2.1.2

Affected Resource(s)

provider "dns"

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

provider "dns" {
    update {
        server = "dc1.mycompany.com"
        gssapi {
            realm = "MYCOMPANY.COM"
        }
    }
}

resource "dns_cname_record" "dns_cname_elb_test" {
    zone = "test-ad-authentication.mycompany.com."
    name  = "test-record"
    cname = "another.mycompany.com."
    ttl   = 60
}

Expected Behavior

When providing environmental variables DNS_UPDATE_USERNAME and DNS_UPDATE_PASSWORD provider should work

Actual Behavior

Provider works if providing username and password in gssapi block, but shows error when setting those values as environmental variables:

Error: RequiredWith

"update.0.gssapi.0.password": all of
`update.0.gssapi.0.password,update.0.gssapi.0.username` must be specified

UPDATE: Environmental variable DNS_UPDATE_REALM works as expected, if not specified in gssapi block, terraform takes values from env variable

Steps to Reproduce

  1. terraform apply

Important Factoids

References

alexpekurovsky avatar Apr 01 '21 08:04 alexpekurovsky

+1

mrh666 avatar Apr 01 '21 10:04 mrh666

+1

Zoorokl avatar Apr 01 '21 10:04 Zoorokl

As a workaround, you need to completely remove update block from provider:

provider dns {
}

and configure everything as environmental variables

export DNS_UPDATE_SERVER="dc1.mycompany.com"
export DNS_UPDATE_REALM="MYCOMPANY.COM"
export DNS_UPDATE_USERNAME="..."
export DNS_UPDATE_PASSWORD="..."

Full list of variable names can be taken from the code: https://github.com/hashicorp/terraform-provider-dns/blob/main/internal/provider/provider.go#L214

The issue is located somewhere in schema itself

alexpekurovsky avatar Apr 01 '21 12:04 alexpekurovsky

For the maintainers, I'm guessing this issue will still persist after #260, as the schema definition was migrated as-is. To fix this, the validators need to be removed from the schema, since the environment variable values are not taken into account during that time, and the various validation logic/errors need to occur in the provider Configure method.

bflad avatar Apr 14 '23 18:04 bflad