Skip to content

Commit

Permalink
Terraform plan diff improvements (#123)
Browse files Browse the repository at this point in the history
* fix: Make allowedIpRanges and pgConfig TypeSet

* fix: Make throughput computed and add DiffSuppressFunc for IOPS

* revert: "fix: Make allowedIpRanges and pgConfig TypeSet"

This reverts commit 12bd4e6.

* fix: Update pkg/provider/resource_cluster.go

Co-authored-by: Matteo <[email protected]>

---------

Co-authored-by: Matteo <[email protected]>
  • Loading branch information
serdardalgic and mbiagetti authored Feb 2, 2023
1 parent fb95017 commit 25294c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ Required:
Optional:

- `iops` (String) IOPS for the selected volume. It can be set to different values depending on your volume type and properties.
- `throughput` (String) Throughput.

Read-Only:

- `throughput` (String) Throughput is automatically calculated by BigAnimal based on the IOPS input.


<a id="nestedblock--allowed_ip_ranges"></a>
Expand Down
11 changes: 9 additions & 2 deletions pkg/provider/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,23 @@ func (c *ClusterResource) Schema() *schema.Resource {
Description: "IOPS for the selected volume. It can be set to different values depending on your volume type and properties.",
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// iops is an optional field.
// If there is already a value set (old != "")
// and there is no new value (new == ""),
// we can suppress this Diff
return new == "" && old != ""
},
},
"size": {
Description: "Size of the volume. It can be set to different values depending on your volume type and properties.",
Type: schema.TypeString,
Required: true,
},
"throughput": {
Description: "Throughput.",
Description: "Throughput is automatically calculated by BigAnimal based on the IOPS input.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"volume_properties": {
Description: "Volume properties in accordance with the selected volume type.",
Expand Down

0 comments on commit 25294c7

Please sign in to comment.