2016-07-13 22:03:41 +02:00
|
|
|
package scaleway
|
|
|
|
|
|
|
|
import (
|
2016-10-27 17:51:34 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/mutexkv"
|
2016-07-13 22:03:41 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"access_key": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ACCESS_KEY", nil),
|
|
|
|
Description: "The API key for Scaleway API operations.",
|
|
|
|
},
|
|
|
|
"organization": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ORGANIZATION", nil),
|
|
|
|
Description: "The Organization ID for Scaleway API operations.",
|
|
|
|
},
|
2016-10-10 20:02:32 +02:00
|
|
|
"region": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_REGION", "par1"),
|
|
|
|
Description: "The Scaleway API region to use.",
|
|
|
|
},
|
2016-07-13 22:03:41 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
|
|
"scaleway_server": resourceScalewayServer(),
|
|
|
|
"scaleway_ip": resourceScalewayIP(),
|
|
|
|
"scaleway_security_group": resourceScalewaySecurityGroup(),
|
|
|
|
"scaleway_security_group_rule": resourceScalewaySecurityGroupRule(),
|
|
|
|
"scaleway_volume": resourceScalewayVolume(),
|
|
|
|
"scaleway_volume_attachment": resourceScalewayVolumeAttachment(),
|
|
|
|
},
|
|
|
|
|
2016-10-15 09:53:32 +02:00
|
|
|
DataSourcesMap: map[string]*schema.Resource{
|
|
|
|
"scaleway_bootscript": dataSourceScalewayBootscript(),
|
2016-10-15 17:16:50 +02:00
|
|
|
"scaleway_image": dataSourceScalewayImage(),
|
2016-10-15 09:53:32 +02:00
|
|
|
},
|
|
|
|
|
2016-07-13 22:03:41 +02:00
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-27 17:51:34 +02:00
|
|
|
var scalewayMutexKV = mutexkv.NewMutexKV()
|
|
|
|
|
2016-07-13 22:03:41 +02:00
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
Organization: d.Get("organization").(string),
|
|
|
|
APIKey: d.Get("access_key").(string),
|
2016-10-10 20:02:32 +02:00
|
|
|
Region: d.Get("region").(string),
|
2016-07-13 22:03:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|