github.com/richardbowden/terraform@v0.6.12-0.20160901200758-30ea22c25211/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  		},
    25  
    26  		ResourcesMap: map[string]*schema.Resource{
    27  			"scaleway_server":              resourceScalewayServer(),
    28  			"scaleway_ip":                  resourceScalewayIP(),
    29  			"scaleway_security_group":      resourceScalewaySecurityGroup(),
    30  			"scaleway_security_group_rule": resourceScalewaySecurityGroupRule(),
    31  			"scaleway_volume":              resourceScalewayVolume(),
    32  			"scaleway_volume_attachment":   resourceScalewayVolumeAttachment(),
    33  		},
    34  
    35  		ConfigureFunc: providerConfigure,
    36  	}
    37  }
    38  
    39  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    40  	config := Config{
    41  		Organization: d.Get("organization").(string),
    42  		APIKey:       d.Get("access_key").(string),
    43  	}
    44  
    45  	return config.Client()
    46  }