diff --git a/builtin/providers/scaleway/resource_scaleway_ip.go b/builtin/providers/scaleway/resource_scaleway_ip.go index 96572e62b..27cb6fb47 100644 --- a/builtin/providers/scaleway/resource_scaleway_ip.go +++ b/builtin/providers/scaleway/resource_scaleway_ip.go @@ -2,6 +2,7 @@ package scaleway import ( "log" + "sync" "github.com/hashicorp/terraform/helper/schema" "github.com/scaleway/scaleway-cli/pkg/api" @@ -30,8 +31,12 @@ func resourceScalewayIP() *schema.Resource { } } +var mu = sync.Mutex{} + func resourceScalewayIPCreate(d *schema.ResourceData, m interface{}) error { scaleway := m.(*Client).scaleway + mu.Lock() + defer mu.Unlock() resp, err := scaleway.NewIP() if err != nil { return err diff --git a/builtin/providers/scaleway/resource_scaleway_ip_test.go b/builtin/providers/scaleway/resource_scaleway_ip_test.go index f32cae1f5..f3381cedf 100644 --- a/builtin/providers/scaleway/resource_scaleway_ip_test.go +++ b/builtin/providers/scaleway/resource_scaleway_ip_test.go @@ -8,6 +8,23 @@ import ( "github.com/hashicorp/terraform/terraform" ) +func TestAccScalewayIP_Count(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckScalewayIPDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckScalewayIPConfig_Count, + Check: resource.ComposeTestCheckFunc( + testAccCheckScalewayIPExists("scaleway_ip.base.0"), + testAccCheckScalewayIPExists("scaleway_ip.base.1"), + ), + }, + }, + }) +} + func TestAccScalewayIP_Basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -129,6 +146,12 @@ resource "scaleway_ip" "base" { } ` +var testAccCheckScalewayIPConfig_Count = ` +resource "scaleway_ip" "base" { + count = 2 +} +` + var testAccCheckScalewayIPAttachConfig = fmt.Sprintf(` resource "scaleway_server" "base" { name = "test"