-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathdata_source_netapp_cloudmanager_aws_fsx.go
75 lines (67 loc) · 1.58 KB
/
data_source_netapp_cloudmanager_aws_fsx.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
70
71
72
73
74
75
package cloudmanager
import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/schema"
)
func dataSourceAWSFSX() *schema.Resource {
return &schema.Resource{
Read: dataSourceAWSFSXRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Optional: true,
},
"id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"lifecycle_status": {
Type: schema.TypeString,
Computed: true,
},
"region": {
Type: schema.TypeString,
Optional: true,
},
"tenant_id": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
func dataSourceAWSFSXRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("Fetching aws fsx: %#v", d)
client := meta.(*Client)
id := d.Get("id").(string)
tenantID := d.Get("tenant_id").(string)
res, err := client.getAWSFSXByID(id, tenantID)
if err != nil {
log.Print("Error getting AWS FSX")
return err
}
d.SetId(res.ID)
err = d.Set("name", res.Name)
if err != nil {
return fmt.Errorf("Error setting fsx name: %s", err.Error())
}
err = d.Set("status", res.ProviderDetails.Status.Status)
if err != nil {
return fmt.Errorf("Error setting fsx status: %s", err.Error())
}
err = d.Set("lifecycle_status", res.ProviderDetails.Status.Lifecycle)
if err != nil {
return fmt.Errorf("Error setting fsx lifecycle: %s", err.Error())
}
err = d.Set("region", res.Region)
if err != nil {
return fmt.Errorf("Error setting fsx region: %s", err.Error())
}
return nil
}