provider/scaleway: expose Region as user facing configuration

This commit is contained in:
Raphael Randschau 2016-10-10 20:02:32 +02:00
parent a5d105da36
commit d98e5200cc
No known key found for this signature in database
GPG Key ID: ECFD707E1275A182
2 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import (
type Config struct {
Organization string
APIKey string
Region string
}
// Client contains scaleway api clients
@ -27,6 +28,7 @@ func (c *Config) Client() (*Client, error) {
c.Organization,
c.APIKey,
scwversion.UserAgent(),
c.Region,
func(s *api.ScalewayAPI) {
s.Logger = newTerraformLogger()
},

View File

@ -21,6 +21,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ORGANIZATION", nil),
Description: "The Organization ID for Scaleway API operations.",
},
"region": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_REGION", "par1"),
Description: "The Scaleway API region to use.",
},
},
ResourcesMap: map[string]*schema.Resource{
@ -40,6 +46,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
Organization: d.Get("organization").(string),
APIKey: d.Get("access_key").(string),
Region: d.Get("region").(string),
}
return config.Client()