github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/builtin/providers/fastly/provider.go (about)

     1  package fastly
     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  			"api_key": &schema.Schema{
    13  				Type:     schema.TypeString,
    14  				Optional: true,
    15  				DefaultFunc: schema.MultiEnvDefaultFunc([]string{
    16  					"FASTLY_API_KEY",
    17  				}, nil),
    18  				Description: "Fastly API Key from https://app.fastly.com/#account",
    19  			},
    20  		},
    21  		ResourcesMap: map[string]*schema.Resource{
    22  			"fastly_service_v1": resourceServiceV1(),
    23  		},
    24  
    25  		ConfigureFunc: providerConfigure,
    26  	}
    27  }
    28  
    29  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    30  	config := Config{
    31  		ApiKey: d.Get("api_key").(string),
    32  	}
    33  	return config.Client()
    34  }