Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForceNew if zone changes on CustomHostname resource #761

Merged
merged 5 commits into from
Aug 17, 2020

Conversation

cdloh
Copy link
Contributor

@cdloh cdloh commented Aug 12, 2020

Custom Hostnames cannot be moved across zones. ForceNew if the zone changes.

@jacobbednarz
Copy link
Member

Thanks for this one @cdloh! Can you please add a test exercising this new condition?

func TestAccCloudflareCustomHostnameUpdate(t *testing.T) {
t.Parallel()
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
domain := os.Getenv("CLOUDFLARE_DOMAIN")
rnd := generateRandomResourceName()
resourceName := "cloudflare_custom_hostname." + rnd
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckCloudflareCustomHostnameWithCustomSSLSettings(zoneID, rnd, domain),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "zone_id", zoneID),
resource.TestCheckResourceAttr(resourceName, "hostname", fmt.Sprintf("%s.%s", rnd, domain)),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.http2", "off"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.min_tls_version", "1.2"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.ciphers.#", "2"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.ciphers.0", "ECDHE-RSA-AES128-GCM-SHA256"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.ciphers.1", "AES128-SHA"),
),
},
{
Config: testAccCheckCloudflareCustomHostnameWithCustomSSLSettingsUpdated(zoneID, rnd, domain),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "zone_id", zoneID),
resource.TestCheckResourceAttr(resourceName, "hostname", fmt.Sprintf("%s.%s", rnd, domain)),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.http2", "off"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.min_tls_version", "1.1"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.ciphers.#", "2"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.ciphers.0", "ECDHE-RSA-AES128-GCM-SHA256"),
resource.TestCheckResourceAttr(resourceName, "ssl.0.settings.0.ciphers.1", "AES128-SHA"),
),
},
},
})
}
is an example of where we do this elsewhere and confirm the values are indeed changing and Terraform is doing the expected thing.

@cdloh
Copy link
Contributor Author

cdloh commented Aug 13, 2020

@jacobbednarz is there another zoneid within the environment to test with? If there isn't another zone I'm unsure how to test it moving across zones.

@jacobbednarz
Copy link
Member

Yep, use CLOUDFLARE_ALT_ZONE_ID and confirm the plan isn't empty.

@jacobbednarz jacobbednarz merged commit 19d5c31 into cloudflare:master Aug 17, 2020
boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this pull request Feb 28, 2022
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