Skip to content

Commit

Permalink
Fix import of zone lockdowns, resolves #134 (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat authored and patryk committed Oct 24, 2018
1 parent f4aaf15 commit 61c97e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions cloudflare/resource_cloudflare_zone_lockdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func resourceCloudflareZoneLockdownImport(d *schema.ResourceData, meta interface
if err != nil {
return nil, fmt.Errorf("couldn't find zone %q while trying to import zone lockdown %q : %q", zoneName, d.Id(), err)
}
d.Set("zone_id", zoneID)
log.Printf("[DEBUG] zone: %s", zoneName)
log.Printf("[DEBUG] zoneID: %s", zoneID)
log.Printf("[DEBUG] Resource ID : %s", zoneLockdownID)
Expand Down
23 changes: 23 additions & 0 deletions cloudflare/resource_cloudflare_zone_lockdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ func TestCloudflareZoneLockdown(t *testing.T) {
})
}

func TestCloudflareZoneLockdown_Import(t *testing.T) {
zone := os.Getenv("CLOUDFLARE_DOMAIN")
rnd := acctest.RandString(10)
name := "cloudflare_zone_lockdown." + rnd

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudflareWAFRuleDestroy,
Steps: []resource.TestStep{
{
Config: testCloudflareZoneLockdownConfig(rnd, zone, "false", "this is notes", rnd+"."+zone+"/*", "ip", "198.51.100.4"),
},
{
ResourceName: name,
ImportStateIdPrefix: fmt.Sprintf("%s/", zone),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testCloudflareZoneLockdownConfig(resourceID, zone, paused, description, url, target, value string) string {
return fmt.Sprintf(`
resource "cloudflare_zone_lockdown" "%[1]s" {
Expand Down

0 comments on commit 61c97e1

Please sign in to comment.