DNSMadeEasy / terraform-provider-dme

Terraform DNSMadeEasy provider
https://www.terraform.io/docs/providers/dme/
Mozilla Public License 2.0
9 stars 31 forks source link

dynamic DNS record IPs overwritten by terraform provider #35

Open angelnu opened 2 years ago

angelnu commented 2 years ago

Terraform Version

Terraform v1.1.7
on linux_amd64
+ provider registry.terraform.io/carlpett/sops v0.6.3
+ provider registry.terraform.io/dnsmadeeasy/dme v1.0.4
+ provider registry.terraform.io/goauthentik/authentik v2022.3.2
+ provider registry.terraform.io/paultyng/unifi v0.34.0
+ provider registry.terraform.io/telkomindonesia/linux v0.7.0

Affected Resource(s)

Terraform Configuration Files

resource "dme_dns_record" "dyn_record" {
  domain_id     = "domain ID"
  name          = "foo-dyndns"
  type          = "A"
  value         = "1.2.3.4"
  ttl           = 600
  dynamic_dns   = true
  password      = "aPassword"

Debug Output

NA

Panic Output

NA

Expected Behavior

value is currently a required parameter. I would expect it to be optional in case of dynamic_dns=true to avoid overriding the dynamic IP on the next terraform apply.

I would expect the following input to be accepted by making value optional:

resource "dme_dns_record" "dyn_record" {
  domain_id     = "domain ID"
  name          = "foo-dyndns"
  type          = "A"
  ttl           = 600
  dynamic_dns   = true
  password      = "aPassword"

Alternative would be to ignore the value when the record already exists.

Actual Behavior

On each terraform apply the IP address uploaded by my router is overriden by hardcoded value in terraform. With this we loose the dynamic capabilities.

Steps to Reproduce

  1. terraform apply
  2. modify the IP address either by the UI or with a dyndns client
  3. terraform apply -> IP change from step 2 is lost.

Important Factoids

NA

References

NA

angelnu commented 2 years ago

As the value must be provided I prepared a PR where an init_value can be provided.