yandex-cloud / terraform-provider-yandex

Terraform Yandex provider
https://www.terraform.io/docs/providers/yandex/
Mozilla Public License 2.0
213 stars 116 forks source link

yandex_cdn_resource, absent custom_host_header field do not reset this field in CDN resource #365

Open baznikin opened 1 year ago

baznikin commented 1 year ago

If you omit custom_host_header in resource definition any changes made with web console do not affect terraform apply - provider simply ignores it.

Steps to reproduce:

  1. create resource
    resource "yandex_cdn_resource" "test" {
    cname = "cdn-kb.example.com"
    origin_protocol = "https"
    origin_group_id = yandex_cdn_origin_group.cdn_kb.id
    }
  2. in web console change "main domain name" to custom Host with some value: image
  3. terraform apply show nothing changed from provider point of view:
    No changes. Your infrastructure matches the configuration.
  4. add custom_host_header to Terraform resource:
    resource "yandex_cdn_resource" "test" {
    cname = "cdn-kb.example.com"
    origin_protocol = "https"
    origin_group_id = yandex_cdn_origin_group.cdn_kb.id
    options {
    custom_host_header = "aaa"
    }
    }
  5. now terraform apply plan this change:

    # yandex_cdn_resource.cdn_kb will be updated in-place
    ~ resource "yandex_cdn_resource" "test" {
        id              = "bc8tcqvnwrgo3bs6vug3"
        # (7 unchanged attributes hidden)
    
      ~ options {
          ~ custom_host_header         = "sss" -> "aaa"
            # (20 unchanged attributes hidden)
        }
    
        # (1 unchanged block hidden)
    }

This issue also persist with terraform import of resource with custom host header:

  1. custom_host_header added to state
  2. terraform apply do not plan to remove it if there is no custom_host_header option in resource
opportunity356 commented 2 months ago

Issue is actual. Reproduces

baznikin commented 2 months ago

This is because of common provider (mis)behavior I mentioned in #465 - if there is no value at all in configuration it completly ignore it and do not try to sync