From 14fcef34feec57f462c6890f3589bd2354a25a7b Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Thu, 10 Mar 2022 14:38:50 +1100 Subject: [PATCH] resource/cloudflare_ruleset: don't attempt to upgrade ratelimit if it isn't set Fixes #1499 --- .changelog/1501.txt | 3 +++ cloudflare/resource_cloudflare_ruleset_migrate.go | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 .changelog/1501.txt diff --git a/.changelog/1501.txt b/.changelog/1501.txt new file mode 100644 index 0000000000..360f6dec29 --- /dev/null +++ b/.changelog/1501.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/cloudflare_ruleset: don't attempt to upgrade ratelimit if it isn't set +``` diff --git a/cloudflare/resource_cloudflare_ruleset_migrate.go b/cloudflare/resource_cloudflare_ruleset_migrate.go index 832a7ebbb2..4097d670af 100644 --- a/cloudflare/resource_cloudflare_ruleset_migrate.go +++ b/cloudflare/resource_cloudflare_ruleset_migrate.go @@ -341,6 +341,10 @@ func resourceCloudflareRulesetSchemaV0() *schema.Resource { } func resourceCloudflareRulesetStateUpgradeV0ToV1(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + if rawState["ratelimit"] == nil { + return rawState, nil + } + rawState["ratelimit"].([]map[string]interface{})[0]["counting_expression"] = rawState["ratelimit"].([]map[string]interface{})[0]["mitigation_expression"] delete(rawState["ratelimit"].([]map[string]interface{})[0], "mitigation_expression")