github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/builtin/providers/cloudstack/provider.go (about) 1 package cloudstack 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_url": &schema.Schema{ 13 Type: schema.TypeString, 14 Required: true, 15 DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_API_URL", nil), 16 }, 17 18 "api_key": &schema.Schema{ 19 Type: schema.TypeString, 20 Required: true, 21 DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_API_KEY", nil), 22 }, 23 24 "secret_key": &schema.Schema{ 25 Type: schema.TypeString, 26 Required: true, 27 DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_SECRET_KEY", nil), 28 }, 29 30 "http_get_only": &schema.Schema{ 31 Type: schema.TypeBool, 32 Required: true, 33 DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_HTTP_GET_ONLY", false), 34 }, 35 36 "timeout": &schema.Schema{ 37 Type: schema.TypeInt, 38 Required: true, 39 DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_TIMEOUT", 300), 40 }, 41 }, 42 43 ResourcesMap: map[string]*schema.Resource{ 44 "cloudstack_disk": resourceCloudStackDisk(), 45 "cloudstack_egress_firewall": resourceCloudStackEgressFirewall(), 46 "cloudstack_firewall": resourceCloudStackFirewall(), 47 "cloudstack_instance": resourceCloudStackInstance(), 48 "cloudstack_ipaddress": resourceCloudStackIPAddress(), 49 "cloudstack_loadbalancer_rule": resourceCloudStackLoadBalancerRule(), 50 "cloudstack_network": resourceCloudStackNetwork(), 51 "cloudstack_network_acl": resourceCloudStackNetworkACL(), 52 "cloudstack_network_acl_rule": resourceCloudStackNetworkACLRule(), 53 "cloudstack_nic": resourceCloudStackNIC(), 54 "cloudstack_port_forward": resourceCloudStackPortForward(), 55 "cloudstack_secondary_ipaddress": resourceCloudStackSecondaryIPAddress(), 56 "cloudstack_ssh_keypair": resourceCloudStackSSHKeyPair(), 57 "cloudstack_template": resourceCloudStackTemplate(), 58 "cloudstack_vpc": resourceCloudStackVPC(), 59 "cloudstack_vpn_connection": resourceCloudStackVPNConnection(), 60 "cloudstack_vpn_customer_gateway": resourceCloudStackVPNCustomerGateway(), 61 "cloudstack_vpn_gateway": resourceCloudStackVPNGateway(), 62 }, 63 64 ConfigureFunc: providerConfigure, 65 } 66 } 67 68 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 69 config := Config{ 70 APIURL: d.Get("api_url").(string), 71 APIKey: d.Get("api_key").(string), 72 SecretKey: d.Get("secret_key").(string), 73 HTTPGETOnly: d.Get("http_get_only").(bool), 74 Timeout: int64(d.Get("timeout").(int)), 75 } 76 77 return config.NewClient() 78 }