Skip to content

Commit

Permalink
feat(rdb): add support for project in rdb instance (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed Oct 7, 2020
1 parent 7240c1e commit 2f4bbab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/resources/rdb_instance_beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ The following arguments are supported:

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

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


## Attributes Reference

Expand Down
12 changes: 12 additions & 0 deletions scaleway/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ func organizationIDSchema() *schema.Schema {
}
}

// projectIDSchema returns a standard schema for a project_id
func projectIDSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
Description: "The project_id you want to attach the resource to",
Optional: true,
ForceNew: true,
Computed: true,
ValidateFunc: validationUUID(),
}
}

// zoneSchema returns a standard schema for a zone
func zoneSchema() *schema.Schema {
return &schema.Schema{
Expand Down
3 changes: 3 additions & 0 deletions scaleway/resource_rdb_instance_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func resourceScalewayRdbInstanceBeta() *schema.Resource {
// Common
"region": regionSchema(),
"organization_id": organizationIDSchema(),
"project_id": projectIDSchema(),
},
}
}
Expand All @@ -127,6 +128,7 @@ func resourceScalewayRdbInstanceBetaCreate(d *schema.ResourceData, m interface{}
createReq := &rdb.CreateInstanceRequest{
Region: region,
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandOrGenerateString(d.Get("name"), "rdb"),
NodeType: d.Get("node_type").(string),
Engine: d.Get("engine").(string),
Expand Down Expand Up @@ -192,6 +194,7 @@ func resourceScalewayRdbInstanceBetaRead(d *schema.ResourceData, m interface{})
_ = d.Set("read_replicas", flattenRdbInstanceReadReplicas(res.ReadReplicas))
_ = d.Set("region", string(region))
_ = d.Set("organization_id", res.OrganizationID)
_ = d.Set("project_id", res.ProjectID)

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

0 comments on commit 2f4bbab

Please sign in to comment.