2015-04-24 18:18:24 +02:00
|
|
|
package azure
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"settings_file": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
2015-05-28 00:50:45 +02:00
|
|
|
Optional: true,
|
2015-04-24 18:18:24 +02:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AZURE_SETTINGS_FILE", nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
"subscription_id": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AZURE_SUBSCRIPTION_ID", ""),
|
|
|
|
},
|
2015-05-28 00:50:45 +02:00
|
|
|
|
|
|
|
"certificate": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AZURE_CERTIFICATE", ""),
|
|
|
|
},
|
|
|
|
|
|
|
|
"management_url": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AZURE_MANAGEMENT_URL", ""),
|
|
|
|
},
|
2015-04-24 18:18:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2015-05-22 15:31:14 +02:00
|
|
|
"azure_data_disk": resourceAzureDataDisk(),
|
2015-04-30 10:58:45 +02:00
|
|
|
"azure_instance": resourceAzureInstance(),
|
|
|
|
"azure_security_group": resourceAzureSecurityGroup(),
|
|
|
|
"azure_virtual_network": resourceAzureVirtualNetwork(),
|
2015-04-24 18:18:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
SettingsFile: d.Get("settings_file").(string),
|
|
|
|
SubscriptionID: d.Get("subscription_id").(string),
|
2015-05-28 00:50:45 +02:00
|
|
|
Certificate: []byte(d.Get("certificate").(string)),
|
|
|
|
ManagementURL: d.Get("management_url").(string),
|
2015-04-24 18:18:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return config.NewClient()
|
|
|
|
}
|