forked from claudusd/terraform-windows-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource_dns_cname.go
69 lines (54 loc) · 1.41 KB
/
resource_dns_cname.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceRecordCname() *schema.Resource {
return &schema.Resource{
Create: createRecordCname,
Read: readRecordCname,
Update: updateRecordCname,
Delete: deleteRecordCname,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"alias": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"zone": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
},
}
}
func createRecordCname(d *schema.ResourceData, m interface{}) error {
c := m.(*Communicator)
c.Connect()
zone := d.Get("zone").(string)
name := d.Get("name").(string)
alias := d.Get("alias").(string)
err := c.AddDNSRecordCname(zone, alias, name)
if err != nil {
return err
}
d.SetId("A_z:" + zone + "_n:" + name + "_alias:" + alias)
return err
}
func deleteRecordCname(d *schema.ResourceData, m interface{}) error {
c := m.(*Communicator)
c.Connect()
alias := d.Get("alias").(string)
return c.RemoveDNSRecordCname(d.Get("zone").(string), alias, d.Get("name").(string))
}
func readRecordCname(d *schema.ResourceData, m interface{}) error {
return nil
}
func updateRecordCname(d *schema.ResourceData, m interface{}) error {
return nil
}