Skip to content

Commit 2f4bbab

Browse files
authored
feat(rdb): add support for project in rdb instance (#605)
1 parent 7240c1e commit 2f4bbab

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

docs/resources/rdb_instance_beta.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ The following arguments are supported:
5858

5959
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the Database Instance is associated with.
6060

61+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the Database Instance is associated with.
62+
6163

6264
## Attributes Reference
6365

scaleway/helpers.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ func organizationIDSchema() *schema.Schema {
227227
}
228228
}
229229

230+
// projectIDSchema returns a standard schema for a project_id
231+
func projectIDSchema() *schema.Schema {
232+
return &schema.Schema{
233+
Type: schema.TypeString,
234+
Description: "The project_id you want to attach the resource to",
235+
Optional: true,
236+
ForceNew: true,
237+
Computed: true,
238+
ValidateFunc: validationUUID(),
239+
}
240+
}
241+
230242
// zoneSchema returns a standard schema for a zone
231243
func zoneSchema() *schema.Schema {
232244
return &schema.Schema{

scaleway/resource_rdb_instance_beta.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func resourceScalewayRdbInstanceBeta() *schema.Resource {
114114
// Common
115115
"region": regionSchema(),
116116
"organization_id": organizationIDSchema(),
117+
"project_id": projectIDSchema(),
117118
},
118119
}
119120
}
@@ -127,6 +128,7 @@ func resourceScalewayRdbInstanceBetaCreate(d *schema.ResourceData, m interface{}
127128
createReq := &rdb.CreateInstanceRequest{
128129
Region: region,
129130
OrganizationID: expandStringPtr(d.Get("organization_id")),
131+
ProjectID: expandStringPtr(d.Get("project_id")),
130132
Name: expandOrGenerateString(d.Get("name"), "rdb"),
131133
NodeType: d.Get("node_type").(string),
132134
Engine: d.Get("engine").(string),
@@ -192,6 +194,7 @@ func resourceScalewayRdbInstanceBetaRead(d *schema.ResourceData, m interface{})
192194
_ = d.Set("read_replicas", flattenRdbInstanceReadReplicas(res.ReadReplicas))
193195
_ = d.Set("region", string(region))
194196
_ = d.Set("organization_id", res.OrganizationID)
197+
_ = d.Set("project_id", res.ProjectID)
195198

196199
// set certificate
197200
cert, err := rdbAPI.GetInstanceCertificate(&rdb.GetInstanceCertificateRequest{

0 commit comments

Comments
 (0)