github.com/mapuri/terraform@v0.7.6-0.20161012203214-7e0408293f97/builtin/providers/scaleway/provider.go (about) 1 package scaleway 2 3 import ( 4 "github.com/hashicorp/terraform/helper/schema" 5 "github.com/hashicorp/terraform/terraform" 6 ) 7 8 // Provider returns a terraform.ResourceProvider. 9 func Provider() terraform.ResourceProvider { 10 return &schema.Provider{ 11 Schema: map[string]*schema.Schema{ 12 "access_key": &schema.Schema{ 13 Type: schema.TypeString, 14 Required: true, 15 DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ACCESS_KEY", nil), 16 Description: "The API key for Scaleway API operations.", 17 }, 18 "organization": &schema.Schema{ 19 Type: schema.TypeString, 20 Required: true, 21 DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_ORGANIZATION", nil), 22 Description: "The Organization ID for Scaleway API operations.", 23 }, 24 "region": &schema.Schema{ 25 Type: schema.TypeString, 26 Optional: true, 27 DefaultFunc: schema.EnvDefaultFunc("SCALEWAY_REGION", "par1"), 28 Description: "The Scaleway API region to use.", 29 }, 30 }, 31 32 ResourcesMap: map[string]*schema.Resource{ 33 "scaleway_server": resourceScalewayServer(), 34 "scaleway_ip": resourceScalewayIP(), 35 "scaleway_security_group": resourceScalewaySecurityGroup(), 36 "scaleway_security_group_rule": resourceScalewaySecurityGroupRule(), 37 "scaleway_volume": resourceScalewayVolume(), 38 "scaleway_volume_attachment": resourceScalewayVolumeAttachment(), 39 }, 40 41 ConfigureFunc: providerConfigure, 42 } 43 } 44 45 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 46 config := Config{ 47 Organization: d.Get("organization").(string), 48 APIKey: d.Get("access_key").(string), 49 Region: d.Get("region").(string), 50 } 51 52 return config.Client() 53 }