Skip to content

Conversation

werwolfby
Copy link
Contributor

@werwolfby werwolfby commented Jun 26, 2025

This error fixes state when I specify netlify_site_domain_settings_changes resource like this:

resource "netlify_site_domain_settings" "my_site" {
  site_id                      = data.netlify_site.my_site.id
  custom_domain       = "www.my.site"
}

This cause changes on each plan/apply:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # netlify_site_domain_settings.my_site will be updated in-place
  ~ resource "netlify_site_domain_settings" "my_site" {
      ~ last_updated                 = "Wednesday, 25-Jun-25 22:58:25 PDT" -> (known after apply)
        # (5 unchanged attributes hidden)
    }

This changes fixes the issue.

This pull request improves the handling of optional fields in the site_domain_settings resource by ensuring null values are explicitly managed and adds a new test case to prevent configuration drift. The changes enhance both the functionality and reliability of the resource.

Enhancements to site_domain_settings resource:

  • Updated the Read method in internal/provider/site_domain_settings_resource.go to explicitly set optional fields (CustomDomain, BranchDeployCustomDomain, and DeployPreviewCustomDomain) to StringNull when they are not provided by the API. This ensures consistent state representation for optional fields.

New test case for preventing configuration drift:

  • Added a new test function TestAccSiteDomainSettingsNullFields in internal/provider/site_domain_settings_resource_test.go. This test verifies that optional fields remain null when not set and ensures no drift occurs when reapplying the same configuration. It also includes an import verification step.

@werwolfby werwolfby requested a review from a team as a code owner June 26, 2025 06:58
Fix constant drift detection in netlify_site_domain_settings by properly
handling null values from the API. The Read function now correctly sets
null values for empty optional fields instead of converting them to
empty strings, preventing Terraform from detecting false differences.
@sarahetter sarahetter force-pushed the fix/netlify_site_domain_settings_changes branch from ee78ec3 to 44a76e0 Compare August 5, 2025 16:34
@sarahetter sarahetter merged commit b591a15 into netlify:main Aug 6, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants