github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/newrelic/provider.go (about)

     1  package newrelic
     2  
     3  import (
     4  	"log"
     5  
     6  	"github.com/hashicorp/terraform/helper/schema"
     7  	"github.com/hashicorp/terraform/terraform"
     8  )
     9  
    10  // Provider represents a resource provider in Terraform
    11  func Provider() terraform.ResourceProvider {
    12  	return &schema.Provider{
    13  		Schema: map[string]*schema.Schema{
    14  			"api_key": {
    15  				Type:        schema.TypeString,
    16  				Required:    true,
    17  				DefaultFunc: schema.EnvDefaultFunc("NEWRELIC_API_KEY", nil),
    18  				Sensitive:   true,
    19  			},
    20  			"api_url": {
    21  				Type:        schema.TypeString,
    22  				Optional:    true,
    23  				DefaultFunc: schema.EnvDefaultFunc("NEWRELIC_API_URL", "https://api.newrelic.com/v2"),
    24  			},
    25  		},
    26  
    27  		DataSourcesMap: map[string]*schema.Resource{
    28  			"newrelic_application": dataSourceNewRelicApplication(),
    29  		},
    30  
    31  		ResourcesMap: map[string]*schema.Resource{
    32  			"newrelic_alert_channel":        resourceNewRelicAlertChannel(),
    33  			"newrelic_alert_condition":      resourceNewRelicAlertCondition(),
    34  			"newrelic_alert_policy":         resourceNewRelicAlertPolicy(),
    35  			"newrelic_alert_policy_channel": resourceNewRelicAlertPolicyChannel(),
    36  		},
    37  
    38  		ConfigureFunc: providerConfigure,
    39  	}
    40  }
    41  
    42  func providerConfigure(data *schema.ResourceData) (interface{}, error) {
    43  	config := Config{
    44  		APIKey: data.Get("api_key").(string),
    45  		APIURL: data.Get("api_url").(string),
    46  	}
    47  	log.Println("[INFO] Initializing New Relic client")
    48  	return config.Client()
    49  }