diff --git a/builtin/providers/scaleway/provider.go b/builtin/providers/scaleway/provider.go index 8ab936efa..c05d6e977 100644 --- a/builtin/providers/scaleway/provider.go +++ b/builtin/providers/scaleway/provider.go @@ -12,16 +12,18 @@ func Provider() terraform.ResourceProvider { Schema: map[string]*schema.Schema{ "access_key": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ACCESS_KEY", nil), Deprecated: "Use `token` instead.", Description: "The API key for Scaleway API operations.", }, - "token": &schema.Schema{ - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_TOKEN", nil), + Type: schema.TypeString, + Required: true, + DefaultFunc: schema.MultiEnvDefaultFunc([]string{ + "SCALEWAY_TOKEN", + "SCALEWAY_ACCESS_KEY", + }, nil), Description: "The API key for Scaleway API operations.", }, "organization": &schema.Schema{ diff --git a/builtin/providers/scaleway/provider_test.go b/builtin/providers/scaleway/provider_test.go index d31d60b54..6575ef8fd 100644 --- a/builtin/providers/scaleway/provider_test.go +++ b/builtin/providers/scaleway/provider_test.go @@ -32,7 +32,9 @@ func testAccPreCheck(t *testing.T) { if v := os.Getenv("SCALEWAY_ORGANIZATION"); v == "" { t.Fatal("SCALEWAY_ORGANIZATION must be set for acceptance tests") } - if v := os.Getenv("SCALEWAY_TOKEN"); v == "" { + tokenFromAccessKey := os.Getenv("SCALEWAY_ACCESS_KEY") + token := os.Getenv("SCALEWAY_TOKEN") + if token == "" && tokenFromAccessKey == "" { t.Fatal("SCALEWAY_TOKEN must be set for acceptance tests") } }