From 9ba17cc2277a641643b24b6a35dcef909b16f7fe Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Tue, 2 Nov 2021 08:56:20 +1100 Subject: [PATCH] resource/cloudflare_argo: call `Read` operation on `Import` Ensures we sync the remote with the local on `Import` operations. Closes #1135 --- .changelog/1295.txt | 3 +++ cloudflare/resource_cloudflare_argo.go | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 .changelog/1295.txt diff --git a/.changelog/1295.txt b/.changelog/1295.txt new file mode 100644 index 0000000000..966b3c5652 --- /dev/null +++ b/.changelog/1295.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/cloudflare_argo: call `Read` for `Import` operations +``` diff --git a/cloudflare/resource_cloudflare_argo.go b/cloudflare/resource_cloudflare_argo.go index abb9c1555f..16c9bfd8fd 100644 --- a/cloudflare/resource_cloudflare_argo.go +++ b/cloudflare/resource_cloudflare_argo.go @@ -53,24 +53,20 @@ func resourceCloudflareArgoRead(d *schema.ResourceData, meta interface{}) error d.SetId(checksum) d.Set("zone_id", zoneID) - if _, ok := d.GetOk("tiered_caching"); ok { - tieredCaching, err := client.ArgoTieredCaching(context.Background(), zoneID) - if err != nil { - return errors.Wrap(err, "failed to get tiered caching setting") - } - - d.Set("tiered_caching", tieredCaching.Value) + tieredCaching, err := client.ArgoTieredCaching(context.Background(), zoneID) + if err != nil { + return errors.Wrap(err, "failed to get tiered caching setting") } - if _, ok := d.GetOk("smart_routing"); ok { - smartRouting, err := client.ArgoSmartRouting(context.Background(), zoneID) - if err != nil { - return errors.Wrap(err, "failed to get smart routing setting") - } + d.Set("tiered_caching", tieredCaching.Value) - d.Set("smart_routing", smartRouting.Value) + smartRouting, err := client.ArgoSmartRouting(context.Background(), zoneID) + if err != nil { + return errors.Wrap(err, "failed to get smart routing setting") } + d.Set("smart_routing", smartRouting.Value) + return nil } @@ -125,5 +121,7 @@ func resourceCloudflareArgoImport(d *schema.ResourceData, meta interface{}) ([]* d.SetId(id) d.Set("zone_id", zoneID) + resourceCloudflareArgoRead(d, meta) + return []*schema.ResourceData{d}, nil }