/
data_source_yandex_mdb_postgresql_database.go
72 lines (69 loc) · 1.69 KB
/
data_source_yandex_mdb_postgresql_database.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
package yandex
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func dataSourceYandexMDBPostgreSQLDatabase() *schema.Resource {
return &schema.Resource{
Read: dataSourceYandexMDBPostgreSQLDatabaseRead,
Schema: map[string]*schema.Schema{
"cluster_id": {
Type: schema.TypeString,
Required: true,
},
"name": {
Type: schema.TypeString,
Required: true,
},
"owner": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"lc_collate": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"lc_type": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"template_db": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"extension": {
Type: schema.TypeSet,
Set: pgExtensionHash,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"version": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
"deletion_protection": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"unspecified", "true", "false"}, false),
},
},
}
}
func dataSourceYandexMDBPostgreSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error {
clusterID := d.Get("cluster_id").(string)
dbname := d.Get("name").(string)
databaseID := constructResourceId(clusterID, dbname)
d.SetId(databaseID)
return resourceYandexMDBPostgreSQLDatabaseRead(d, meta)
}