github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/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", 900), 40 }, 41 }, 42 43 ResourcesMap: map[string]*schema.Resource{ 44 "cloudstack_affinity_group": resourceCloudStackAffinityGroup(), 45 "cloudstack_disk": resourceCloudStackDisk(), 46 "cloudstack_egress_firewall": resourceCloudStackEgressFirewall(), 47 "cloudstack_firewall": resourceCloudStackFirewall(), 48 "cloudstack_instance": resourceCloudStackInstance(), 49 "cloudstack_ipaddress": resourceCloudStackIPAddress(), 50 "cloudstack_loadbalancer_rule": resourceCloudStackLoadBalancerRule(), 51 "cloudstack_network": resourceCloudStackNetwork(), 52 "cloudstack_network_acl": resourceCloudStackNetworkACL(), 53 "cloudstack_network_acl_rule": resourceCloudStackNetworkACLRule(), 54 "cloudstack_nic": resourceCloudStackNIC(), 55 "cloudstack_port_forward": resourceCloudStackPortForward(), 56 "cloudstack_private_gateway": resourceCloudStackPrivateGateway(), 57 "cloudstack_secondary_ipaddress": resourceCloudStackSecondaryIPAddress(), 58 "cloudstack_security_group": resourceCloudStackSecurityGroup(), 59 "cloudstack_security_group_rule": resourceCloudStackSecurityGroupRule(), 60 "cloudstack_ssh_keypair": resourceCloudStackSSHKeyPair(), 61 "cloudstack_static_nat": resourceCloudStackStaticNAT(), 62 "cloudstack_static_route": resourceCloudStackStaticRoute(), 63 "cloudstack_template": resourceCloudStackTemplate(), 64 "cloudstack_vpc": resourceCloudStackVPC(), 65 "cloudstack_vpn_connection": resourceCloudStackVPNConnection(), 66 "cloudstack_vpn_customer_gateway": resourceCloudStackVPNCustomerGateway(), 67 "cloudstack_vpn_gateway": resourceCloudStackVPNGateway(), 68 }, 69 70 ConfigureFunc: providerConfigure, 71 } 72 } 73 74 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 75 config := Config{ 76 APIURL: d.Get("api_url").(string), 77 APIKey: d.Get("api_key").(string), 78 SecretKey: d.Get("secret_key").(string), 79 HTTPGETOnly: d.Get("http_get_only").(bool), 80 Timeout: int64(d.Get("timeout").(int)), 81 } 82 83 return config.NewClient() 84 }