From d756a2be31837b4ae6dbfea40d61ae023d9f3487 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Fri, 9 Sep 2022 11:24:11 +0200 Subject: [PATCH 01/22] functional cloudflare_account resource --- internal/provider/provider.go | 1 + .../provider/resource_cloudflare_account.go | 148 ++++++++++++++++++ .../provider/schema_cloudflare_account.go | 28 ++++ 3 files changed, 177 insertions(+) create mode 100644 internal/provider/resource_cloudflare_account.go create mode 100644 internal/provider/schema_cloudflare_account.go diff --git a/internal/provider/provider.go b/internal/provider/provider.go index d5a21ca7f0..cbc01cee9e 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -269,6 +269,7 @@ func New(version string) func() *schema.Provider { "cloudflare_zone_lockdown": resourceCloudflareZoneLockdown(), "cloudflare_zone_settings_override": resourceCloudflareZoneSettingsOverride(), "cloudflare_zone": resourceCloudflareZone(), + "cloudflare_account": resourceCloudflareAccount(), }, } diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go new file mode 100644 index 0000000000..c5d357d1e7 --- /dev/null +++ b/internal/provider/resource_cloudflare_account.go @@ -0,0 +1,148 @@ +package provider + +import ( + "context" + "errors" + "fmt" + "log" + + "github.com/MakeNowJust/heredoc/v2" + cloudflare "github.com/cloudflare/cloudflare-go" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +const ( + accountTypeStandard = "standard" + accountTypeEnterprise = "enterprise" +) + +func resourceCloudflareAccount() *schema.Resource { + return &schema.Resource{ + Schema: resourceCloudflareAccountSchema(), + CreateContext: resourceCloudflareAccountCreate, + ReadContext: resourceCloudflareAccountRead, + UpdateContext: resourceCloudflareAccountUpdate, + DeleteContext: resourceCloudflareAccountDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Description: heredoc.Doc(` + Provides a Cloudflare Account resource. Account is the basic resource for + working with Cloudflare zones, teams and users. Requires the tenant entitlement + `), + } +} + +func resourceCloudflareAccountCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*cloudflare.API) + accountName := d.Get("name").(string) + var accountType string + if d.Get("type").(string) == "" { + accountType = accountTypeStandard + } else if d.Get("type").(string) == accountTypeStandard || d.Get("type").(string) == accountTypeEnterprise { + accountType = d.Get("type").(string) + } else { + return diag.FromErr(fmt.Errorf("invalid account type %s", d.Get("type").(string))) + } + + tflog.Info(ctx, fmt.Sprintf("Creating Cloudflare Account: name %s", accountName)) + + account := cloudflare.Account{ + Name: accountName, + Type: accountType, + } + acc, err := client.CreateAccount(ctx, account) + + if err != nil { + return diag.FromErr(fmt.Errorf("error creating account %q: %w", accountName, err)) + } + + d.SetId(acc.ID) + + return resourceCloudflareAccountRead(ctx, d, meta) +} + +func getCloudflareAccontFromId(accountID string, client *cloudflare.API, ctx context.Context) (cloudflare.Account, error) { + accs, _, err := client.Accounts(ctx, cloudflare.AccountsListParams{}) + if err != nil { + return cloudflare.Account{}, err + } else { + for _, acc := range accs { + if acc.ID == accountID { + return acc, nil + } + } + + return cloudflare.Account{}, fmt.Errorf("Account %s does not exist", accountID) + } +} + +func resourceCloudflareAccountRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*cloudflare.API) + accountID := d.Id() + + foundAcc, err := getCloudflareAccontFromId(accountID, client, ctx) + tflog.Debug(ctx, fmt.Sprintf("AccountDetails error: %#v", err)) + + if err != nil || foundAcc.ID == "" { + var notFoundError *cloudflare.NotFoundError + if errors.As(err, ¬FoundError) { + tflog.Info(ctx, fmt.Sprintf("Account %s no longer exists", d.Id())) + d.SetId("") + return nil + } + return diag.FromErr(fmt.Errorf("error finding Account %q: %w", d.Id(), err)) + } + + tflog.Debug(ctx, fmt.Sprintf("AccountDetails: %#v", foundAcc)) + + d.Set("name", foundAcc.Name) + d.Set("type", foundAcc.Type) + d.Set("enforce_twofactor", foundAcc.Settings.EnforceTwoFactor) + + return nil +} + +func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*cloudflare.API) + accountID := d.Id() + foundAcc, err := getCloudflareAccontFromId(accountID, client, ctx) + + tflog.Debug(ctx, fmt.Sprintf("AccountDetails error: %#v", err)) + + log.Printf("[INFO] Updating Cloudflare Account: id %s", accountID) + + if accountName, ok := d.GetOkExists("name"); ok && d.HasChange("name") { + foundAcc.Name = accountName.(string) + client.UpdateAccount(ctx, accountID, foundAcc) + } + + if accountType, ok := d.GetOkExists("type"); ok && d.HasChange("type") { + foundAcc.Type = accountType.(string) + client.UpdateAccount(ctx, accountID, foundAcc) + } + + if enforce_twofactor, ok := d.GetOkExists("enforce_twofactor"); ok && d.HasChange("enforce_twofactor") { + foundAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) + client.UpdateAccount(ctx, accountID, foundAcc) + } + + return resourceCloudflareAccountRead(ctx, d, meta) +} + +func resourceCloudflareAccountDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*cloudflare.API) + accountID := d.Id() + + log.Printf("[INFO] Deleting Cloudflare Account: id %s", accountID) + + err := client.DeleteAccount(ctx, accountID) + + if err != nil { + return diag.FromErr(fmt.Errorf("error deleting Cloudflare Account: %w", err)) + } + + return nil +} diff --git a/internal/provider/schema_cloudflare_account.go b/internal/provider/schema_cloudflare_account.go new file mode 100644 index 0000000000..fd228f4799 --- /dev/null +++ b/internal/provider/schema_cloudflare_account.go @@ -0,0 +1,28 @@ +package provider + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + +func resourceCloudflareAccountSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "The name of the account that is displayed in the Cloudflare dashboard.", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Description: "Valid values are standard (default) and enterprise. For self-serve customers, use standard. For enterprise customers, use enterprise.", + Default: accountTypeStandard, + ValidateFunc: validation.StringInSlice([]string{accountTypeEnterprise, accountTypeStandard}, false), + ForceNew: true, + }, + "enforce_twofactor": { + Description: "Whether 2FA is enforced on the account.", + Type: schema.TypeBool, + Default: false, + Optional: true, + }, + } +} From 4b34348925548bf9e177457128299f0c4f97d3a3 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Fri, 9 Sep 2022 11:36:51 +0200 Subject: [PATCH 02/22] adding basic test for cloudflare_account resource --- .../resource_cloudflare_account_test.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 internal/provider/resource_cloudflare_account_test.go diff --git a/internal/provider/resource_cloudflare_account_test.go b/internal/provider/resource_cloudflare_account_test.go new file mode 100644 index 0000000000..81b3ad77fd --- /dev/null +++ b/internal/provider/resource_cloudflare_account_test.go @@ -0,0 +1,45 @@ +package provider + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccCloudflareAccount(t *testing.T) { + t.Parallel() + + rnd := generateRandomResourceName() + name := fmt.Sprintf("cloudflare_account.%s", rnd) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + ProviderFactories: providerFactories, + Steps: []resource.TestStep{ + { + Config: testAccCheckCloudflareAccountName(fmt.Sprintf("%s old", rnd)), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + name, "name", fmt.Sprintf("%s old", rnd)), + ), + }, + { + Config: testAccCheckCloudflareAccountName(fmt.Sprintf("%s new", rnd)), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + name, "name", fmt.Sprintf("%s new", rnd)), + ), + }, + }, + }) +} + +func testAccCheckCloudflareAccountName(name string) string { + return fmt.Sprintf(` + resource "cloudflare_account" "%[1]s" { + name = "%[1]s" + }`, name) +} From 82ef4cde09ff0194e1100ce9a6aaed76d28d2694 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Fri, 9 Sep 2022 11:39:41 +0200 Subject: [PATCH 03/22] adding changelog --- .changelog/1902.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/1902.txt diff --git a/.changelog/1902.txt b/.changelog/1902.txt new file mode 100644 index 0000000000..72bc98f74b --- /dev/null +++ b/.changelog/1902.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +cloudflare_account +``` From e0e4273d4b128ade1b99aa34ee6a5d0acd57ca83 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Fri, 9 Sep 2022 11:46:24 +0200 Subject: [PATCH 04/22] verifying UpdateAccount return value --- internal/provider/resource_cloudflare_account.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index c5d357d1e7..62cfae0229 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -116,20 +116,22 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData if accountName, ok := d.GetOkExists("name"); ok && d.HasChange("name") { foundAcc.Name = accountName.(string) - client.UpdateAccount(ctx, accountID, foundAcc) } if accountType, ok := d.GetOkExists("type"); ok && d.HasChange("type") { foundAcc.Type = accountType.(string) - client.UpdateAccount(ctx, accountID, foundAcc) } if enforce_twofactor, ok := d.GetOkExists("enforce_twofactor"); ok && d.HasChange("enforce_twofactor") { foundAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) - client.UpdateAccount(ctx, accountID, foundAcc) } - return resourceCloudflareAccountRead(ctx, d, meta) + _, err = client.UpdateAccount(ctx, accountID, foundAcc) + if err != nil { + return diag.FromErr(fmt.Errorf("error updating Account %q: %w", d.Id(), err)) + } else { + return resourceCloudflareAccountRead(ctx, d, meta) + } } func resourceCloudflareAccountDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { From 26f36dc53c94a2e1946fa35211dcbb3a8840f482 Mon Sep 17 00:00:00 2001 From: Arnaud Aubert <109612999+mlhnono68@users.noreply.github.com> Date: Wed, 14 Sep 2022 10:59:10 +0200 Subject: [PATCH 05/22] Update internal/provider/resource_cloudflare_account.go Co-authored-by: Jacob Bednarz --- internal/provider/resource_cloudflare_account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 62cfae0229..4f5f83eab5 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -30,7 +30,7 @@ func resourceCloudflareAccount() *schema.Resource { }, Description: heredoc.Doc(` Provides a Cloudflare Account resource. Account is the basic resource for - working with Cloudflare zones, teams and users. Requires the tenant entitlement + working with Cloudflare zones, teams and users. `), } } From 50c8a98a293721144075275c1fa031baafa82b5a Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 11:19:39 +0200 Subject: [PATCH 06/22] validate account type by schema validation only --- internal/provider/resource_cloudflare_account.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 4f5f83eab5..77f64b8f96 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -38,14 +38,7 @@ func resourceCloudflareAccount() *schema.Resource { func resourceCloudflareAccountCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*cloudflare.API) accountName := d.Get("name").(string) - var accountType string - if d.Get("type").(string) == "" { - accountType = accountTypeStandard - } else if d.Get("type").(string) == accountTypeStandard || d.Get("type").(string) == accountTypeEnterprise { - accountType = d.Get("type").(string) - } else { - return diag.FromErr(fmt.Errorf("invalid account type %s", d.Get("type").(string))) - } + accountType := d.Get("type").(string) tflog.Info(ctx, fmt.Sprintf("Creating Cloudflare Account: name %s", accountName)) From 9f6a575cb97b518bdf2bd10824a6c2af33ebb06b Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 11:33:53 +0200 Subject: [PATCH 07/22] removing redundant getCloudflareAccontFromId --- .../provider/resource_cloudflare_account.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 77f64b8f96..8c2ce8c284 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -57,26 +57,11 @@ func resourceCloudflareAccountCreate(ctx context.Context, d *schema.ResourceData return resourceCloudflareAccountRead(ctx, d, meta) } -func getCloudflareAccontFromId(accountID string, client *cloudflare.API, ctx context.Context) (cloudflare.Account, error) { - accs, _, err := client.Accounts(ctx, cloudflare.AccountsListParams{}) - if err != nil { - return cloudflare.Account{}, err - } else { - for _, acc := range accs { - if acc.ID == accountID { - return acc, nil - } - } - - return cloudflare.Account{}, fmt.Errorf("Account %s does not exist", accountID) - } -} - func resourceCloudflareAccountRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*cloudflare.API) accountID := d.Id() - foundAcc, err := getCloudflareAccontFromId(accountID, client, ctx) + foundAcc, _, err := client.Account(ctx, accountID) tflog.Debug(ctx, fmt.Sprintf("AccountDetails error: %#v", err)) if err != nil || foundAcc.ID == "" { @@ -101,7 +86,7 @@ func resourceCloudflareAccountRead(ctx context.Context, d *schema.ResourceData, func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*cloudflare.API) accountID := d.Id() - foundAcc, err := getCloudflareAccontFromId(accountID, client, ctx) + foundAcc, _, err := client.Account(ctx, accountID) tflog.Debug(ctx, fmt.Sprintf("AccountDetails error: %#v", err)) From 4778e7281670e3b180159751bedafa5157d373c8 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 13:37:13 +0200 Subject: [PATCH 08/22] cleaning useless error debug finding accountID --- internal/provider/resource_cloudflare_account.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 8c2ce8c284..a3acae0f72 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -62,8 +62,6 @@ func resourceCloudflareAccountRead(ctx context.Context, d *schema.ResourceData, accountID := d.Id() foundAcc, _, err := client.Account(ctx, accountID) - tflog.Debug(ctx, fmt.Sprintf("AccountDetails error: %#v", err)) - if err != nil || foundAcc.ID == "" { var notFoundError *cloudflare.NotFoundError if errors.As(err, ¬FoundError) { @@ -87,8 +85,9 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData client := meta.(*cloudflare.API) accountID := d.Id() foundAcc, _, err := client.Account(ctx, accountID) - - tflog.Debug(ctx, fmt.Sprintf("AccountDetails error: %#v", err)) + if err != nil || foundAcc.ID == "" { + return diag.FromErr(fmt.Errorf("error finding Account %q: %w", d.Id(), err)) + } log.Printf("[INFO] Updating Cloudflare Account: id %s", accountID) From eb17af3d02dc1280121b5ef41b1ee8b60f0fd0f5 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 13:43:46 +0200 Subject: [PATCH 09/22] replacing GetOkExists by GetOk for account properties --- internal/provider/resource_cloudflare_account.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index a3acae0f72..f6b0b8be89 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -91,15 +91,15 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData log.Printf("[INFO] Updating Cloudflare Account: id %s", accountID) - if accountName, ok := d.GetOkExists("name"); ok && d.HasChange("name") { + if accountName, ok := d.GetOk("name"); ok && d.HasChange("name") { foundAcc.Name = accountName.(string) } - if accountType, ok := d.GetOkExists("type"); ok && d.HasChange("type") { + if accountType, ok := d.GetOk("type"); ok && d.HasChange("type") { foundAcc.Type = accountType.(string) } - if enforce_twofactor, ok := d.GetOkExists("enforce_twofactor"); ok && d.HasChange("enforce_twofactor") { + if enforce_twofactor, ok := d.GetOk("enforce_twofactor"); ok && d.HasChange("enforce_twofactor") { foundAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) } From 3dc566a54b4e945feb15b5c008dc706d3010edc3 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 15:58:16 +0200 Subject: [PATCH 10/22] adding support for error 1001 to be ignored --- internal/provider/resource_cloudflare_account.go | 14 +++++++++----- internal/provider/schema_cloudflare_account.go | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index f6b0b8be89..0cb5d453cf 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -89,22 +89,26 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData return diag.FromErr(fmt.Errorf("error finding Account %q: %w", d.Id(), err)) } - log.Printf("[INFO] Updating Cloudflare Account: id %s", accountID) + tflog.Debug(ctx, fmt.Sprintf("[INFO] Updating Cloudflare Account: id %s", accountID)) if accountName, ok := d.GetOk("name"); ok && d.HasChange("name") { foundAcc.Name = accountName.(string) } - if accountType, ok := d.GetOk("type"); ok && d.HasChange("type") { - foundAcc.Type = accountType.(string) - } - if enforce_twofactor, ok := d.GetOk("enforce_twofactor"); ok && d.HasChange("enforce_twofactor") { foundAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) } _, err = client.UpdateAccount(ctx, accountID, foundAcc) if err != nil { + if ferr, ok := err.(*cloudflare.RequestError); ok { + errCodes := ferr.ErrorCodes() + if len(errCodes) == 1 && errCodes[0] == 1001 { + tflog.Debug(ctx, "Ignoring error 1001: Updating account type is not supported from client api") + return resourceCloudflareAccountRead(ctx, d, meta) + } + } + tflog.Error(ctx, fmt.Sprintf("%#v", err)) return diag.FromErr(fmt.Errorf("error updating Account %q: %w", d.Id(), err)) } else { return resourceCloudflareAccountRead(ctx, d, meta) diff --git a/internal/provider/schema_cloudflare_account.go b/internal/provider/schema_cloudflare_account.go index fd228f4799..f15740b751 100644 --- a/internal/provider/schema_cloudflare_account.go +++ b/internal/provider/schema_cloudflare_account.go @@ -16,7 +16,7 @@ func resourceCloudflareAccountSchema() map[string]*schema.Schema { Description: "Valid values are standard (default) and enterprise. For self-serve customers, use standard. For enterprise customers, use enterprise.", Default: accountTypeStandard, ValidateFunc: validation.StringInSlice([]string{accountTypeEnterprise, accountTypeStandard}, false), - ForceNew: true, + ForceNew: true, // Because "Updating account type is not supported from client api" }, "enforce_twofactor": { Description: "Whether 2FA is enforced on the account.", From 69d4f39ca97931ed93c29a2661fffb30971ea742 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 16:00:27 +0200 Subject: [PATCH 11/22] tflog instead of printf --- internal/provider/resource_cloudflare_account.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 0cb5d453cf..0c559da959 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -4,8 +4,6 @@ import ( "context" "errors" "fmt" - "log" - "github.com/MakeNowJust/heredoc/v2" cloudflare "github.com/cloudflare/cloudflare-go" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -89,7 +87,7 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData return diag.FromErr(fmt.Errorf("error finding Account %q: %w", d.Id(), err)) } - tflog.Debug(ctx, fmt.Sprintf("[INFO] Updating Cloudflare Account: id %s", accountID)) + tflog.Debug(ctx, fmt.Sprintf("Updating Cloudflare Account: id %s", accountID)) if accountName, ok := d.GetOk("name"); ok && d.HasChange("name") { foundAcc.Name = accountName.(string) @@ -119,7 +117,7 @@ func resourceCloudflareAccountDelete(ctx context.Context, d *schema.ResourceData client := meta.(*cloudflare.API) accountID := d.Id() - log.Printf("[INFO] Deleting Cloudflare Account: id %s", accountID) + tflog.Debug(ctx, fmt.Sprintf("Deleting Cloudflare Account: id %s", accountID)) err := client.DeleteAccount(ctx, accountID) From f628d5a2d861275e68127c980b39d2e92279932a Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 16:31:45 +0200 Subject: [PATCH 12/22] simpler if --- internal/provider/resource_cloudflare_account.go | 6 +++--- internal/provider/resource_cloudflare_account_member.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 0c559da959..7913713beb 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -38,7 +38,7 @@ func resourceCloudflareAccountCreate(ctx context.Context, d *schema.ResourceData accountName := d.Get("name").(string) accountType := d.Get("type").(string) - tflog.Info(ctx, fmt.Sprintf("Creating Cloudflare Account: name %s", accountName)) + tflog.Debug(ctx, fmt.Sprintf("Creating Cloudflare Account: name %s", accountName)) account := cloudflare.Account{ Name: accountName, @@ -108,9 +108,9 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData } tflog.Error(ctx, fmt.Sprintf("%#v", err)) return diag.FromErr(fmt.Errorf("error updating Account %q: %w", d.Id(), err)) - } else { - return resourceCloudflareAccountRead(ctx, d, meta) } + + return resourceCloudflareAccountRead(ctx, d, meta) } func resourceCloudflareAccountDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/internal/provider/resource_cloudflare_account_member.go b/internal/provider/resource_cloudflare_account_member.go index 3b86eb93ea..ddd1007947 100644 --- a/internal/provider/resource_cloudflare_account_member.go +++ b/internal/provider/resource_cloudflare_account_member.go @@ -66,7 +66,7 @@ func resourceCloudflareAccountMemberRead(ctx context.Context, d *schema.Resource func resourceCloudflareAccountMemberDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*cloudflare.API) - tflog.Info(ctx, fmt.Sprintf("Deleting Cloudflare account member ID: %s", d.Id())) + tflog.Debug(ctx, fmt.Sprintf("Deleting Cloudflare account member ID: %s", d.Id())) var accountID string if d.Get("account_id").(string) != "" { From 9cfa4185e5450bbe5f5a0dbb3a51cad03bf43be7 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 16:59:00 +0200 Subject: [PATCH 13/22] adding example --- examples/resources/cloudflare_account/import.sh | 1 + examples/resources/cloudflare_account/resource.tf | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 examples/resources/cloudflare_account/import.sh create mode 100644 examples/resources/cloudflare_account/resource.tf diff --git a/examples/resources/cloudflare_account/import.sh b/examples/resources/cloudflare_account/import.sh new file mode 100644 index 0000000000..fd73ab5e6b --- /dev/null +++ b/examples/resources/cloudflare_account/import.sh @@ -0,0 +1 @@ +$ terraform import cloudflare_account.example \ No newline at end of file diff --git a/examples/resources/cloudflare_account/resource.tf b/examples/resources/cloudflare_account/resource.tf new file mode 100644 index 0000000000..1578c58516 --- /dev/null +++ b/examples/resources/cloudflare_account/resource.tf @@ -0,0 +1,5 @@ +resource "cloudflare_account" "account" { + name = "some-enterprise-account" + type = "enterprise" + enforce_twofactor = true +} \ No newline at end of file From 15dc2c5569912a3eaf2e40f3cdb62b2fd82cc686 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 17:04:40 +0200 Subject: [PATCH 14/22] after make docs --- docs/resources/access_rule.md | 4 ++-- docs/resources/email_routing_catch_all.md | 25 ++++------------------- docs/resources/email_routing_rule.md | 2 ++ 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/docs/resources/access_rule.md b/docs/resources/access_rule.md index 5d7e06da4a..b9c7d648b2 100644 --- a/docs/resources/access_rule.md +++ b/docs/resources/access_rule.md @@ -66,9 +66,9 @@ resource "cloudflare_access_rule" "office_network" { ### Optional -- `account_id` (String) The account identifier to target for the resource. Must provide only one of `account_id`, `zone_id`. +- `account_id` (String) The account identifier to target for the resource. - `notes` (String) A personal note about the rule. Typically used as a reminder or explanation for the rule. -- `zone_id` (String) The zone identifier to target for the resource. Must provide only one of `account_id`, `zone_id`. +- `zone_id` (String) The zone identifier to target for the resource. ### Read-Only diff --git a/docs/resources/email_routing_catch_all.md b/docs/resources/email_routing_catch_all.md index 579fb8e43a..8a554a62dc 100644 --- a/docs/resources/email_routing_catch_all.md +++ b/docs/resources/email_routing_catch_all.md @@ -1,33 +1,14 @@ --- -page_title: "cloudflare_email_routing_rule_catch_all Resource - Cloudflare" +page_title: "cloudflare_email_routing_catch_all Resource - Cloudflare" subcategory: "" description: |- Provides a resource for managing Email Routing Addresses catch all behaviour. --- -# cloudflare_email_routing_rule_catch_all (Resource) +# cloudflare_email_routing_catch_all (Resource) Provides a resource for managing Email Routing Addresses catch all behaviour. -## Example Usage - -```terraform -resource "cloudflare_email_routing_rule_catch_all" "main" { - zone_id = "0da42c8d2132a9ddaf714f9e7c920711" - name = "terraform rule" - enabled = true - - matcher { - type = "all" - } - - action { - type = "forward" - value = ["destinationaddress@example.net"] - } -} -``` - ## Schema @@ -69,3 +50,5 @@ Optional: - `field` (String) Field for type matcher. - `value` (String) Value for matcher. + + diff --git a/docs/resources/email_routing_rule.md b/docs/resources/email_routing_rule.md index ceef954dcc..9f83406840 100644 --- a/docs/resources/email_routing_rule.md +++ b/docs/resources/email_routing_rule.md @@ -69,3 +69,5 @@ Optional: - `field` (String) Field for type matcher. - `value` (String) Value for matcher. + + From 732a819d6fc1944243a151bc12bd49f095637c46 Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 17:09:12 +0200 Subject: [PATCH 15/22] additional account.md --- docs/resources/account.md | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 docs/resources/account.md diff --git a/docs/resources/account.md b/docs/resources/account.md new file mode 100644 index 0000000000..78032217a7 --- /dev/null +++ b/docs/resources/account.md @@ -0,0 +1,44 @@ +--- +page_title: "cloudflare_account Resource - Cloudflare" +subcategory: "" +description: |- + Provides a Cloudflare Account resource. Account is the basic resource for + working with Cloudflare zones, teams and users. +--- + +# cloudflare_account (Resource) + +Provides a Cloudflare Account resource. Account is the basic resource for +working with Cloudflare zones, teams and users. + +## Example Usage + +```terraform +resource "cloudflare_account" "account" { + name = "some-enterprise-account" + type = "enterprise" + enforce_twofactor = true +} +``` + +## Schema + +### Required + +- `name` (String) The name of the account that is displayed in the Cloudflare dashboard. + +### Optional + +- `enforce_twofactor` (Boolean) Whether 2FA is enforced on the account. Defaults to `false`. +- `type` (String) Valid values are standard (default) and enterprise. For self-serve customers, use standard. For enterprise customers, use enterprise. Defaults to `standard`. + +### Read-Only + +- `id` (String) The ID of this resource. + +## Import + +Import is supported using the following syntax: +```shell +$ terraform import cloudflare_account.example +``` From b8011c7f1f89c0be5b4dc06fb1582e9a634750fa Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Wed, 14 Sep 2022 19:03:13 +0200 Subject: [PATCH 16/22] using errors.As --- internal/provider/resource_cloudflare_account.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 7913713beb..09701d58c1 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -99,8 +99,9 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData _, err = client.UpdateAccount(ctx, accountID, foundAcc) if err != nil { - if ferr, ok := err.(*cloudflare.RequestError); ok { - errCodes := ferr.ErrorCodes() + var cfError *cloudflare.RequestError + if errors.As(err, &cfError) { + errCodes := cfError.ErrorCodes() if len(errCodes) == 1 && errCodes[0] == 1001 { tflog.Debug(ctx, "Ignoring error 1001: Updating account type is not supported from client api") return resourceCloudflareAccountRead(ctx, d, meta) From bdaf4210d567297d5be5afdfda59c9e3e49e428d Mon Sep 17 00:00:00 2001 From: mlhnono68 Date: Thu, 15 Sep 2022 11:53:15 +0200 Subject: [PATCH 17/22] omitting Account.Type on update to prevent 1001 error --- internal/provider/resource_cloudflare_account.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 09701d58c1..5259a5e37d 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -97,16 +97,9 @@ func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData foundAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) } + foundAcc.Type = "" // To avoid error 1001: Updating account type is not supported from client api _, err = client.UpdateAccount(ctx, accountID, foundAcc) if err != nil { - var cfError *cloudflare.RequestError - if errors.As(err, &cfError) { - errCodes := cfError.ErrorCodes() - if len(errCodes) == 1 && errCodes[0] == 1001 { - tflog.Debug(ctx, "Ignoring error 1001: Updating account type is not supported from client api") - return resourceCloudflareAccountRead(ctx, d, meta) - } - } tflog.Error(ctx, fmt.Sprintf("%#v", err)) return diag.FromErr(fmt.Errorf("error updating Account %q: %w", d.Id(), err)) } From 1632568f0b3d4eaecfc8b141cbf9e58698644e76 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Wed, 21 Sep 2022 10:40:30 +1000 Subject: [PATCH 18/22] clean up examples --- docs/resources/account.md | 6 +++--- examples/resources/cloudflare_account/resource.tf | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/resources/account.md b/docs/resources/account.md index 78032217a7..eadf476ab4 100644 --- a/docs/resources/account.md +++ b/docs/resources/account.md @@ -14,9 +14,9 @@ working with Cloudflare zones, teams and users. ## Example Usage ```terraform -resource "cloudflare_account" "account" { - name = "some-enterprise-account" - type = "enterprise" +resource "cloudflare_account" "example" { + name = "some-enterprise-account" + type = "enterprise" enforce_twofactor = true } ``` diff --git a/examples/resources/cloudflare_account/resource.tf b/examples/resources/cloudflare_account/resource.tf index 1578c58516..77ba9d04db 100644 --- a/examples/resources/cloudflare_account/resource.tf +++ b/examples/resources/cloudflare_account/resource.tf @@ -1,5 +1,5 @@ -resource "cloudflare_account" "account" { - name = "some-enterprise-account" - type = "enterprise" +resource "cloudflare_account" "example" { + name = "some-enterprise-account" + type = "enterprise" enforce_twofactor = true -} \ No newline at end of file +} From 879670fb05f40200173889cec1b6a810f3648746 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Wed, 21 Sep 2022 10:40:59 +1000 Subject: [PATCH 19/22] fix test cases and building updated accounts --- .../provider/resource_cloudflare_account.go | 21 ++++++++----------- .../resource_cloudflare_account_test.go | 10 ++++----- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/internal/provider/resource_cloudflare_account.go b/internal/provider/resource_cloudflare_account.go index 5259a5e37d..2cd1539b30 100644 --- a/internal/provider/resource_cloudflare_account.go +++ b/internal/provider/resource_cloudflare_account.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/MakeNowJust/heredoc/v2" cloudflare "github.com/cloudflare/cloudflare-go" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -28,7 +29,7 @@ func resourceCloudflareAccount() *schema.Resource { }, Description: heredoc.Doc(` Provides a Cloudflare Account resource. Account is the basic resource for - working with Cloudflare zones, teams and users. + working with Cloudflare zones, teams and users. `), } } @@ -60,7 +61,7 @@ func resourceCloudflareAccountRead(ctx context.Context, d *schema.ResourceData, accountID := d.Id() foundAcc, _, err := client.Account(ctx, accountID) - if err != nil || foundAcc.ID == "" { + if err != nil { var notFoundError *cloudflare.NotFoundError if errors.As(err, ¬FoundError) { tflog.Info(ctx, fmt.Sprintf("Account %s no longer exists", d.Id())) @@ -82,23 +83,19 @@ func resourceCloudflareAccountRead(ctx context.Context, d *schema.ResourceData, func resourceCloudflareAccountUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*cloudflare.API) accountID := d.Id() - foundAcc, _, err := client.Account(ctx, accountID) - if err != nil || foundAcc.ID == "" { - return diag.FromErr(fmt.Errorf("error finding Account %q: %w", d.Id(), err)) - } tflog.Debug(ctx, fmt.Sprintf("Updating Cloudflare Account: id %s", accountID)) - if accountName, ok := d.GetOk("name"); ok && d.HasChange("name") { - foundAcc.Name = accountName.(string) + updatedAcc := cloudflare.Account{} + if accountName, ok := d.GetOk("name"); ok { + updatedAcc.Name = accountName.(string) } - if enforce_twofactor, ok := d.GetOk("enforce_twofactor"); ok && d.HasChange("enforce_twofactor") { - foundAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) + if enforce_twofactor, ok := d.GetOk("enforce_twofactor"); ok { + updatedAcc.Settings.EnforceTwoFactor = enforce_twofactor.(bool) } - foundAcc.Type = "" // To avoid error 1001: Updating account type is not supported from client api - _, err = client.UpdateAccount(ctx, accountID, foundAcc) + _, err := client.UpdateAccount(ctx, accountID, updatedAcc) if err != nil { tflog.Error(ctx, fmt.Sprintf("%#v", err)) return diag.FromErr(fmt.Errorf("error updating Account %q: %w", d.Id(), err)) diff --git a/internal/provider/resource_cloudflare_account_test.go b/internal/provider/resource_cloudflare_account_test.go index 81b3ad77fd..a901aa7afa 100644 --- a/internal/provider/resource_cloudflare_account_test.go +++ b/internal/provider/resource_cloudflare_account_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccCloudflareAccount(t *testing.T) { +func TestAccCloudflareAccount_Basic(t *testing.T) { t.Parallel() rnd := generateRandomResourceName() @@ -20,17 +20,17 @@ func TestAccCloudflareAccount(t *testing.T) { ProviderFactories: providerFactories, Steps: []resource.TestStep{ { - Config: testAccCheckCloudflareAccountName(fmt.Sprintf("%s old", rnd)), + Config: testAccCheckCloudflareAccountName(fmt.Sprintf("%s_old", rnd)), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - name, "name", fmt.Sprintf("%s old", rnd)), + name, "name", fmt.Sprintf("%s_old", rnd)), ), }, { - Config: testAccCheckCloudflareAccountName(fmt.Sprintf("%s new", rnd)), + Config: testAccCheckCloudflareAccountName(fmt.Sprintf("%s_new", rnd)), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - name, "name", fmt.Sprintf("%s new", rnd)), + name, "name", fmt.Sprintf("%s_new", rnd)), ), }, }, From d321272ba89f8bdb6d036cc613648f8ee591fda2 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Wed, 21 Sep 2022 10:41:21 +1000 Subject: [PATCH 20/22] sort resources alphabetically --- internal/provider/provider.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f63166b9fd..8883755974 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -200,6 +200,7 @@ func New(version string) func() *schema.Provider { "cloudflare_access_rule": resourceCloudflareAccessRule(), "cloudflare_access_service_token": resourceCloudflareAccessServiceToken(), "cloudflare_account_member": resourceCloudflareAccountMember(), + "cloudflare_account": resourceCloudflareAccount(), "cloudflare_api_shield": resourceCloudflareAPIShield(), "cloudflare_api_token": resourceCloudflareApiToken(), "cloudflare_argo_tunnel": resourceCloudflareArgoTunnel(), @@ -255,13 +256,13 @@ func New(version string) func() *schema.Provider { "cloudflare_tunnel_route": resourceCloudflareTunnelRoute(), "cloudflare_tunnel_virtual_network": resourceCloudflareTunnelVirtualNetwork(), "cloudflare_user_agent_blocking_rule": resourceCloudflareUserAgentBlockingRules(), - "cloudflare_web3_hostname": resourceCloudflareWeb3Hostname(), "cloudflare_waf_group": resourceCloudflareWAFGroup(), "cloudflare_waf_override": resourceCloudflareWAFOverride(), "cloudflare_waf_package": resourceCloudflareWAFPackage(), "cloudflare_waf_rule": resourceCloudflareWAFRule(), "cloudflare_waiting_room_event": resourceCloudflareWaitingRoomEvent(), "cloudflare_waiting_room": resourceCloudflareWaitingRoom(), + "cloudflare_web3_hostname": resourceCloudflareWeb3Hostname(), "cloudflare_worker_cron_trigger": resourceCloudflareWorkerCronTrigger(), "cloudflare_worker_route": resourceCloudflareWorkerRoute(), "cloudflare_worker_script": resourceCloudflareWorkerScript(), @@ -272,7 +273,6 @@ func New(version string) func() *schema.Provider { "cloudflare_zone_lockdown": resourceCloudflareZoneLockdown(), "cloudflare_zone_settings_override": resourceCloudflareZoneSettingsOverride(), "cloudflare_zone": resourceCloudflareZone(), - "cloudflare_account": resourceCloudflareAccount(), }, } From 6359a83ebd4e0f472af1cd029e8fd2390a55111b Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Wed, 21 Sep 2022 10:52:36 +1000 Subject: [PATCH 21/22] fix schema definition --- docs/resources/account.md | 2 +- internal/provider/schema_cloudflare_account.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/resources/account.md b/docs/resources/account.md index eadf476ab4..6762e0edf2 100644 --- a/docs/resources/account.md +++ b/docs/resources/account.md @@ -30,7 +30,7 @@ resource "cloudflare_account" "example" { ### Optional - `enforce_twofactor` (Boolean) Whether 2FA is enforced on the account. Defaults to `false`. -- `type` (String) Valid values are standard (default) and enterprise. For self-serve customers, use standard. For enterprise customers, use enterprise. Defaults to `standard`. +- `type` (String) Account type. Available values: `enterprise`, `standard`. Defaults to `standard`. ### Read-Only diff --git a/internal/provider/schema_cloudflare_account.go b/internal/provider/schema_cloudflare_account.go index f15740b751..3eeeb449af 100644 --- a/internal/provider/schema_cloudflare_account.go +++ b/internal/provider/schema_cloudflare_account.go @@ -1,7 +1,11 @@ package provider -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) func resourceCloudflareAccountSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ @@ -13,10 +17,10 @@ func resourceCloudflareAccountSchema() map[string]*schema.Schema { "type": { Type: schema.TypeString, Optional: true, - Description: "Valid values are standard (default) and enterprise. For self-serve customers, use standard. For enterprise customers, use enterprise.", + Description: fmt.Sprintf("Account type. %s", renderAvailableDocumentationValuesStringSlice([]string{accountTypeEnterprise, accountTypeStandard})), Default: accountTypeStandard, ValidateFunc: validation.StringInSlice([]string{accountTypeEnterprise, accountTypeStandard}, false), - ForceNew: true, // Because "Updating account type is not supported from client api" + ForceNew: true, // "Updating account type is not supported from client api" }, "enforce_twofactor": { Description: "Whether 2FA is enforced on the account.", From 4ebc3652cf35a4c9cf62e13a7b6e545f60551869 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Wed, 21 Sep 2022 10:56:33 +1000 Subject: [PATCH 22/22] fix `email_routing_catch_all docs` --- docs/resources/email_routing_catch_all.md | 19 ++++++++++++++++++- .../resource.tf | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) rename examples/resources/{cloudflare_email_routing_rule_catch_all => cloudflare_email_routing_catch_all}/resource.tf (67%) diff --git a/docs/resources/email_routing_catch_all.md b/docs/resources/email_routing_catch_all.md index 8a554a62dc..0789776eb8 100644 --- a/docs/resources/email_routing_catch_all.md +++ b/docs/resources/email_routing_catch_all.md @@ -9,7 +9,24 @@ description: |- Provides a resource for managing Email Routing Addresses catch all behaviour. - +## Example Usage + +```terraform +resource "cloudflare_email_routing_catch_all" "example" { + zone_id = "0da42c8d2132a9ddaf714f9e7c920711" + name = "example catch all" + enabled = true + + matcher { + type = "all" + } + + action { + type = "forward" + value = ["destinationaddress@example.net"] + } +} +``` ## Schema diff --git a/examples/resources/cloudflare_email_routing_rule_catch_all/resource.tf b/examples/resources/cloudflare_email_routing_catch_all/resource.tf similarity index 67% rename from examples/resources/cloudflare_email_routing_rule_catch_all/resource.tf rename to examples/resources/cloudflare_email_routing_catch_all/resource.tf index a99be1dac4..744b476ede 100644 --- a/examples/resources/cloudflare_email_routing_rule_catch_all/resource.tf +++ b/examples/resources/cloudflare_email_routing_catch_all/resource.tf @@ -1,6 +1,6 @@ -resource "cloudflare_email_routing_rule_catch_all" "main" { +resource "cloudflare_email_routing_catch_all" "example" { zone_id = "0da42c8d2132a9ddaf714f9e7c920711" - name = "terraform rule" + name = "example catch all" enabled = true matcher {