Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudflare_ip_list import set correct account_id #916

Merged
merged 2 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions cloudflare/import_resource_cloudflare_ip_list_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cloudflare

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccCloudflareIPList_Import(t *testing.T) {
rnd := generateRandomResourceName()
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID")
name := "cloudflare_ip_list." + rnd

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckCloudflareIPList(rnd, rnd, rnd, accountID),
},
{
ResourceName: name,
ImportStateIdPrefix: fmt.Sprintf("%s/", accountID),
ImportState: true,
ImportStateVerify: true,
},
},
})
}
3 changes: 1 addition & 2 deletions cloudflare/resource_cloudflare_ip_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func resourceCloudflareIPListCreate(d *schema.ResourceData, meta interface{}) er
}

func resourceCloudflareIPListImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
client := meta.(*cloudflare.API)
attributes := strings.SplitN(d.Id(), "/", 2)

if len(attributes) != 2 {
Expand All @@ -97,7 +96,7 @@ func resourceCloudflareIPListImport(d *schema.ResourceData, meta interface{}) ([

accountID, listID := attributes[0], attributes[1]
d.SetId(listID)
client.AccountID = accountID
d.Set("account_id", accountID)

resourceCloudflareIPListRead(d, meta)

Expand Down