diff --git a/.changelog/2219.txt b/.changelog/2219.txt index 6bafcdac428..112625b37d7 100644 --- a/.changelog/2219.txt +++ b/.changelog/2219.txt @@ -7,5 +7,5 @@ resource/cloudflare_spectrum_application: `edge_ips` now contains nested attribu ``` ```release-note:breaking-change -resource/cloudflare_spectrum_application: `edge_ips.type` and `edge_ips.connectivity` are now required fields +resource/cloudflare_spectrum_application: `edge_ips.type` is now a required field ``` diff --git a/docs/resources/spectrum_application.md b/docs/resources/spectrum_application.md index 607aca6093e..1a3d86836f6 100644 --- a/docs/resources/spectrum_application.md +++ b/docs/resources/spectrum_application.md @@ -31,9 +31,8 @@ resource "cloudflare_spectrum_application" "example" { ] edge_ips { - type = "static" - connectivity = "all" - ips = ["203.0.113.1", "203.0.113.2"] + type = "static" + ips = ["203.0.113.1", "203.0.113.2"] } } ``` @@ -77,11 +76,11 @@ Required: Required: -- `connectivity` (String) The IP versions supported for inbound connections on Spectrum anycast IPs. Available values: `all`, `ipv4`, `ipv6`. - `type` (String) The type of edge IP configuration specified. Available values: `dynamic`, `static`. Optional: +- `connectivity` (String) The IP versions supported for inbound connections on Spectrum anycast IPs. Required when `type` is not `static`. Available values: `all`, `ipv4`, `ipv6`. - `ips` (Set of String) The collection of customer owned IPs to broadcast via anycast for this hostname and application. Requires [Bring Your Own IP](https://developers.cloudflare.com/spectrum/getting-started/byoip/) provisioned. diff --git a/examples/resources/cloudflare_spectrum_application/resource.tf b/examples/resources/cloudflare_spectrum_application/resource.tf index 09557dcbedc..198c218b356 100644 --- a/examples/resources/cloudflare_spectrum_application/resource.tf +++ b/examples/resources/cloudflare_spectrum_application/resource.tf @@ -13,8 +13,7 @@ resource "cloudflare_spectrum_application" "example" { ] edge_ips { - type = "static" - connectivity = "all" - ips = ["203.0.113.1", "203.0.113.2"] + type = "static" + ips = ["203.0.113.1", "203.0.113.2"] } } diff --git a/internal/sdkv2provider/resource_cloudflare_spectrum_application.go b/internal/sdkv2provider/resource_cloudflare_spectrum_application.go index b1e78722a12..c45c51b7a78 100644 --- a/internal/sdkv2provider/resource_cloudflare_spectrum_application.go +++ b/internal/sdkv2provider/resource_cloudflare_spectrum_application.go @@ -228,8 +228,6 @@ func flattenEdgeIPs(edgeIPs *cloudflare.SpectrumApplicationEdgeIPs) []map[string if edgeIPs.Connectivity != nil { flattened["connectivity"] = edgeIPs.Connectivity.String() - } else { - flattened["connectivity"] = cloudflare.SpectrumConnectivityAll } ips := []string{} @@ -284,8 +282,10 @@ func applicationFromResource(d *schema.ResourceData) cloudflare.SpectrumApplicat application.EdgeIPs = &cloudflare.SpectrumApplicationEdgeIPs{} - c := edgeIPsConnectivityFromString(d.Get("edge_ips.0.connectivity").(string)) - application.EdgeIPs.Connectivity = &c + if d.Get("edge_ips.0.connectivity").(string) != "" { + c := edgeIPsConnectivityFromString(d.Get("edge_ips.0.connectivity").(string)) + application.EdgeIPs.Connectivity = &c + } application.EdgeIPs.Type = edgeIPsTypeFromString(d.Get("edge_ips.0.type").(string)) diff --git a/internal/sdkv2provider/resource_cloudflare_spectrum_application_test.go b/internal/sdkv2provider/resource_cloudflare_spectrum_application_test.go index 9abaf47f1d4..ab57ffadf29 100644 --- a/internal/sdkv2provider/resource_cloudflare_spectrum_application_test.go +++ b/internal/sdkv2provider/resource_cloudflare_spectrum_application_test.go @@ -237,30 +237,6 @@ func TestAccCloudflareSpectrumApplication_EdgeIPConnectivity(t *testing.T) { }) } -func TestAccCloudflareSpectrumApplication_EdgeIPsWithoutConnectivity(t *testing.T) { - var spectrumApp cloudflare.SpectrumApplication - domain := os.Getenv("CLOUDFLARE_DOMAIN") - zoneID := os.Getenv("CLOUDFLARE_ZONE_ID") - rnd := generateRandomResourceName() - name := "cloudflare_spectrum_application." + rnd - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: providerFactories, - Steps: []resource.TestStep{ - { - Config: testAccCheckCloudflareSpectrumApplicationConfigEdgeIPsWithoutConnectivity(zoneID, domain, rnd), - Check: resource.ComposeTestCheckFunc( - testAccCheckCloudflareSpectrumApplicationExists(name, &spectrumApp), - testAccCheckCloudflareSpectrumApplicationIDIsValid(name), - resource.TestCheckResourceAttr(name, "edge_ips.0.ips.#", "1"), - resource.TestCheckTypeSetElemAttr(name, "edge_ips.0.ips.*", "172.65.64.13"), - ), - }, - }, - }) -} - func TestAccCloudflareSpectrumApplication_EdgeIPsMultiple(t *testing.T) { var spectrumApp cloudflare.SpectrumApplication domain := os.Getenv("CLOUDFLARE_DOMAIN") @@ -500,7 +476,6 @@ resource "cloudflare_spectrum_application" "%[3]s" { origin_port = 22 edge_ips { type = "static" - connectivity = "all" ips = ["172.65.64.13"] } }`, zoneID, zoneName, ID) @@ -521,7 +496,6 @@ resource "cloudflare_spectrum_application" "%[3]s" { origin_port = 22 edge_ips { type = "static" - connectivity = "all" ips = [%[4]s] } }`, zoneID, zoneName, ID, IPs) diff --git a/internal/sdkv2provider/schema_cloudflare_spectrum_application.go b/internal/sdkv2provider/schema_cloudflare_spectrum_application.go index 4e32f47a7c7..69657829fa5 100644 --- a/internal/sdkv2provider/schema_cloudflare_spectrum_application.go +++ b/internal/sdkv2provider/schema_cloudflare_spectrum_application.go @@ -144,9 +144,9 @@ func resourceCloudflareSpectrumApplicationSchema() map[string]*schema.Schema { }, "connectivity": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validation.StringInSlice([]string{"all", "ipv4", "ipv6"}, false), - Description: fmt.Sprintf("The IP versions supported for inbound connections on Spectrum anycast IPs. %s", renderAvailableDocumentationValuesStringSlice([]string{"all", "ipv4", "ipv6"})), + Description: fmt.Sprintf("The IP versions supported for inbound connections on Spectrum anycast IPs. Required when `type` is not `static`. %s", renderAvailableDocumentationValuesStringSlice([]string{"all", "ipv4", "ipv6"})), }, "ips": { Type: schema.TypeSet,