-
Notifications
You must be signed in to change notification settings - Fork 258
/
datasource_digitalocean_reserved_ip.go
46 lines (41 loc) · 1.27 KB
/
datasource_digitalocean_reserved_ip.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
package digitalocean
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceDigitalOceanReservedIP() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceDigitalOceanReservedIPRead,
Schema: map[string]*schema.Schema{
"ip_address": {
Type: schema.TypeString,
Required: true,
Description: "reserved ip address",
ValidateFunc: validation.NoZeroValues,
},
// computed attributes
"urn": {
Type: schema.TypeString,
Computed: true,
Description: "the uniform resource name for the reserved ip",
},
"region": {
Type: schema.TypeString,
Computed: true,
Description: "the region that the reserved ip is reserved to",
},
"droplet_id": {
Type: schema.TypeInt,
Computed: true,
Description: "the droplet id that the reserved ip has been assigned to.",
},
},
}
}
func dataSourceDigitalOceanReservedIPRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
ipAddress := d.Get("ip_address").(string)
d.SetId(ipAddress)
return resourceDigitalOceanReservedIPRead(ctx, d, meta)
}