github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/datadog/provider.go (about)

     1  package datadog
     2  
     3  import (
     4  	"log"
     5  
     6  	"github.com/hashicorp/terraform/helper/schema"
     7  	"github.com/hashicorp/terraform/terraform"
     8  )
     9  
    10  func Provider() terraform.ResourceProvider {
    11  	return &schema.Provider{
    12  		Schema: map[string]*schema.Schema{
    13  			"api_key": &schema.Schema{
    14  				Type:        schema.TypeString,
    15  				Required:    true,
    16  				DefaultFunc: schema.EnvDefaultFunc("DATADOG_API_KEY", nil),
    17  			},
    18  			"app_key": &schema.Schema{
    19  				Type:        schema.TypeString,
    20  				Required:    true,
    21  				DefaultFunc: schema.EnvDefaultFunc("DATADOG_APP_KEY", nil),
    22  			},
    23  		},
    24  
    25  		ResourcesMap: map[string]*schema.Resource{
    26  			"datadog_monitor":   resourceDatadogMonitor(),
    27  			"datadog_timeboard": resourceDatadogTimeboard(),
    28  		},
    29  
    30  		ConfigureFunc: providerConfigure,
    31  	}
    32  }
    33  
    34  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    35  
    36  	config := Config{
    37  		APIKey: d.Get("api_key").(string),
    38  		APPKey: d.Get("app_key").(string),
    39  	}
    40  
    41  	log.Println("[INFO] Initializing Datadog client")
    42  	return config.Client()
    43  }