-
Notifications
You must be signed in to change notification settings - Fork 6
/
provider.go
44 lines (39 loc) · 1.09 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
twilioc "github.com/tulip/twiliogo"
)
func provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"account_sid": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("TWILIO_SID", nil),
Description: "The SID (application ID) for the the Twilio API",
},
"auth_token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("TWILIO_AUTH_TOKEN", nil),
Description: "Oauth token for the the Twilio API",
},
},
ResourcesMap: map[string]*schema.Resource{
"twilio_phonenumber": resourcePhonenumber(),
},
ConfigureFunc: providerConfigure,
}
}
type twilioMeta struct {
Client *twilioc.TwilioClient
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
return &twilioMeta{
Client: twilioc.NewClient(
d.Get("account_sid").(string),
d.Get("auth_token").(string),
),
}, nil
}