From 07a83056f40cd1d02538636ebe2bc1e89d33540e Mon Sep 17 00:00:00 2001 From: Nicky Semenza Date: Wed, 22 Mar 2023 10:40:26 -0700 Subject: [PATCH 1/2] when geo_restrictions aren't set, set as nil and not empty string previously, we would send `geo_restrictions":{"label":""}`, now we won't send anything at all. Resolves #2318 ```release-note:bug resource/cloudflare_custom_ssl: fix json sent to API when geo_restrictions are not used (#1472, #2318) ``` --- internal/sdkv2provider/resource_cloudflare_custom_ssl.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/sdkv2provider/resource_cloudflare_custom_ssl.go b/internal/sdkv2provider/resource_cloudflare_custom_ssl.go index 74716c2d79..c48e082390 100644 --- a/internal/sdkv2provider/resource_cloudflare_custom_ssl.go +++ b/internal/sdkv2provider/resource_cloudflare_custom_ssl.go @@ -245,8 +245,12 @@ func expandToZoneCustomSSLOptions(ctx context.Context, d *schema.ResourceData) ( for id, value := range cert.(map[string]interface{}) { var newValue interface{} if id == "geo_restrictions" { - newValue = cloudflare.ZoneCustomSSLGeoRestrictions{ - Label: value.(string), + if value == "" { + newValue = nil + } else { + newValue = cloudflare.ZoneCustomSSLGeoRestrictions{ + Label: value.(string), + } } } else { newValue = value.(string) From e1a65cc01083ecd64ddc4f82d5c1cdee8005316f Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Fri, 24 Mar 2023 09:57:35 +1100 Subject: [PATCH 2/2] add changelog entry --- .changelog/2319.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2319.txt diff --git a/.changelog/2319.txt b/.changelog/2319.txt new file mode 100644 index 0000000000..e35b4f76bb --- /dev/null +++ b/.changelog/2319.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/cloudflare_custom_ssl: fix json sent to API when geo_restrictions are not used +```