Skip to content

Commit

Permalink
Merge pull request #573 from RedisLabs/remove-status-from-db-resources
Browse files Browse the repository at this point in the history
Remove latest_backup_status and latest_import_status from resources
  • Loading branch information
matpimenta authored Dec 5, 2024
2 parents 6a4f34a + 23f4abc commit 2fc3d1f
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 651 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)

# 2.0.0 (Unreleased)

### Changed

- Upgraded the provider to use `v0.21.0` of the [rediscloud-go-api](https://github.com/RedisLabs/rediscloud-go-api) which handles API rate limits gracefully.

### Removed

- `latest_backup_status` and `latest_import_status` from `rediscloud_active_active_subscription_database`,
`rediscloud_active_active_subscription_regions`, `rediscloud_subscription_database` and `rediscloud_essentials_database`.
Users should use the equivalent data sources instead.

# 1.9.0 (9th Oct 2024)

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ data "rediscloud_active_active_subscription_database" "example" {
* `global_modules` - A list of modules to be enabled on all deployments of this database.
* `public_endpoint` - Public endpoint to access the database.
* `private_endpoint` - Private endpoint to access the database.
* `latest_backup_statuses` A list of latest_backup_status objects, documented below.
* `latest_import_status` - A latest_import_status object, documented below.`
* `latest_backup_statuses` A list of `latest_backup_status` objects, documented below.
* `latest_import_status` - A `latest_import_status` object, documented below.`
* `tags` - A string/string map of all Tags associated with this database.

The `latest_backup_status` object and `latest_import_status` block contains:
The `latest_backup_status` block contains:

* `region` - The region within the Cloud Provider where this database is hosted.
* `error` - An error block, in case this lookup failed, documented below.
* `response` - A detail block, documented below.

The `latest_import_status` block contains:

* `error` - An error block, in case this lookup failed, documented below.
* `response` - A detail block, documented below.
Expand Down
152 changes: 152 additions & 0 deletions docs/guides/migration-guide-v2.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
page_title: "Migrating to version v2.X.X"
---

# Migrating to version v2.X.X

V2 introduced breaking changes with the removal the `latest_backup_status` and `latest_import_status` attributes from `rediscloud_active_active_subscription_database`,
`rediscloud_active_active_subscription_regions`, `rediscloud_subscription_database` and `rediscloud_essentials_database` resources.
With this change, plans will be much faster to compute and apply. If you rely on one those attributes, they are still available under the respective database data sources.
See the examples below on how to migrate to use the data sources.

## Active-Active Subscription Database:

**Before:**
```hcl
resource "rediscloud_active_active_subscription_database" "database_resource" {
# ...
}
output "latest_backup_status" {
value = nonsensitive({
for r in rediscloud_active_active_subscription_database.database_resource.override_region :
r.name => r.latest_backup_status
})
}
output "latest_import_status" {
value = rediscloud_active_active_subscription_database.database_resource.latest_import_status
}
```

**After:**

```hcl
data "rediscloud_active_active_subscription_database" "database" {
subscription_id = "..."
name = "..."
}
output "latest_backup_status" {
value = {
for r in data.rediscloud_active_active_subscription_database.database.latest_backup_statuses :
r.region => r
}
}
output "latest_import_status" {
value = data.rediscloud_active_active_subscription_database.database.latest_import_status
}
```

## Active-Active Subscription Regions:

**Before:**
```hcl
resource "rediscloud_active_active_subscription_regions" "regions_resource" {
# ...
}
output "latest_backup_status" {
value = {
for r in rediscloud_active_active_subscription_regions.regions_resource.region :
r.region => r.database[*].latest_backup_status)
}
}
```

**After:**

```hcl
data "rediscloud_active_active_subscription_database" "database" {
subscription_id = "..."
name = "..."
}
output "latest_backup_status" {
value = {
for r in data.rediscloud_active_active_subscription_database.database.latest_backup_statuses :
r.region => flatten(r.response[*].status)
}
}
```

## Pro Subscriptions:

**Before:**
```hcl
resource "rediscloud_subscription_database" "database_resource" {
# ...
}
output "latest_backup_status" {
value = rediscloud_subscription_database.database_resource.latest_backup_status
}
output "latest_import_status" {
value = rediscloud_subscription_database.database_resource.latest_import_status
}
```

**After:**

```hcl
data "rediscloud_database" "database" {
subscription_id = "..."
name = "..."
}
output "latest_backup_status" {
value = data.rediscloud_database.database.latest_backup_status
}
output "latest_import_status" {
value = data.rediscloud_database.database.latest_import_status
}
```

## Essentials Subscriptions:

**Before:**
```hcl
resource "rediscloud_essentials_database" "database_resource" {
# ...
}
output "latest_backup_status" {
value = rediscloud_essentials_database.database_resource.latest_backup_status
}
output "latest_import_status" {
value = rediscloud_essentials_database.database_resource.latest_import_status
}
```

**After:**

```hcl
data "rediscloud_essentials_database" "database" {
subscription_id = "..."
name = "..."
}
output "latest_backup_status" {
value = data.rediscloud_essentials_database.database.latest_backup_status
}
output "latest_import_status" {
value = data.rediscloud_essentials_database.database.latest_import_status
}
```

26 changes: 0 additions & 26 deletions docs/resources/rediscloud_active_active_subscription_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,32 +143,6 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l
* `db_id` - Identifier of the database created
* `public_endpoint` - A map of which public endpoints can to access the database per region, uses region name as key.
* `private_endpoint` - A map of which private endpoints can to access the database per region, uses region name as key.
* `override_region.latest_backup_status` - On each override_region block, the latest_backup_status is reported, an object documented below.
* `latest_import_status` - A latest_import_status object, documented below.

The `latest_backup_status` object and `latest_import_status` block contains:

* `error` - An error block, in case this lookup failed, documented below.
* `response` - A detail block, documented below.

The `error` block in `latest_backup_status` and `latest_import_status` contains:

* `type` - The type of error encountered while looking up the status of the last import.
* `description` - A description of the error encountered while looking up the status of the last import.
* `status` - Any particular HTTP status code associated with the erroneous status check.

The `response` block `latest_backup_status` contains:

* `status` - The status of the last backup operation.
* `last_backup_time` - When the last backup operation occurred.
* `failure_reason` - If a failure, why the backup operation failed.

The `response` block `latest_import_status` contains:

* `status` - The status of the last import operation.
* `last_import_time` - When the last import operation occurred.
* `failure_reason` - If a failure, why the import operation failed.
* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry.

## Import
`rediscloud_active_active_subscription_database` can be imported using the ID of the Active-Active subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g.
Expand Down
21 changes: 0 additions & 21 deletions docs/resources/rediscloud_active_active_subscription_regions.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,6 @@ The `database` block supports:
* `local_write_operations_per_second` - (Required) Local write operations per second for this active-active region
* `local_read_operations_per_second` - (Required) Local read operations per second for this active-active region

## Attribute Reference

* `latest_backup_status` - A latest_backup_status object, documented below.

The `latest_backup_status` block contains:

* `error` - An error block, in case this lookup failed, documented below.
* `response` - A detail block, documented below.

The `error` block in both `latest_backup_status` contains:

* `type` - The type of error encountered while looking up the status of the last import.
* `description` - A description of the error encountered while looking up the status of the last import.
* `status` - Any particular HTTP status code associated with the erroneous status check.

The `response` block `latest_backup_status` contains:

* `status` - The status of the last backup operation.
* `last_backup_time` - When the last backup operation occurred.
* `failure_reason` - If a failure, why the backup operation failed.

### Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down
26 changes: 0 additions & 26 deletions docs/resources/rediscloud_essentials_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,6 @@ Each `modules` entry provides the following attributes:
* `activated_on` - When this database was activated.
* `public_endpoint` - Public endpoint to access the database.
* `private_endpoint` - Private endpoint to access the database.
* `latest_backup_status` - A latest_backup_status object, documented below.
* `latest_import_status` - A latest_import_status object, documented below.

The `latest_backup_status` and `latest_import_status` blocks contain:

* `error` - An error block, in case this lookup failed, documented below.
* `response` - A detail block, documented below.

The `error` block in both `latest_backup_status` and `latest_import_status` contains:

* `type` - The type of error encountered while looking up the status of the last backup/import.
* `description` - A description of the error encountered while looking up the status of the last backup/import.
* `status` - Any particular HTTP status code associated with the erroneous status check.

The `response` block `latest_backup_status` contains:

* `status` - The status of the last backup operation.
* `last_backup_time` - When the last backup operation occurred.
* `failure_reason` - If a failure, why the backup operation failed.

The `response` block `latest_import_status` contains:

* `status` - The status of the last import operation.
* `last_import_time` - When the last import operation occurred.
* `failure_reason` - If a failure, why the import operation failed.
* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry.

## Import
`rediscloud_essentials_database` can be imported using the ID of the subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g.
Expand Down
28 changes: 1 addition & 27 deletions docs/resources/rediscloud_subscription_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,32 +155,6 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/l
* `db_id` - Identifier of the database created
* `public_endpoint` - Public endpoint to access the database
* `private_endpoint` - Private endpoint to access the database
* `latest_backup_status` - A latest_backup_status object, documented below.
* `latest_import_status` - A latest_import_status object, documented below.

The `latest_backup_status` and `latest_import_status` blocks contain:

* `error` - An error block, in case this lookup failed, documented below.
* `response` - A detail block, documented below.

The `error` block in both `latest_backup_status` and `latest_import_status` contains:

* `type` - The type of error encountered while looking up the status of the last backup/import.
* `description` - A description of the error encountered while looking up the status of the last backup/import.
* `status` - Any particular HTTP status code associated with the erroneous status check.

The `response` block `latest_backup_status` contains:

* `status` - The status of the last backup operation.
* `last_backup_time` - When the last backup operation occurred.
* `failure_reason` - If a failure, why the backup operation failed.

The `response` block `latest_import_status` contains:

* `status` - The status of the last import operation.
* `last_import_time` - When the last import operation occurred.
* `failure_reason` - If a failure, why the import operation failed.
* `failure_reason_params` - Parameters of the failure, if appropriate, in the form of a list of objects each with a `key` entry and a `value` entry.

## Import
`rediscloud_subscription_database` can be imported using the ID of the subscription and the ID of the database in the format {subscription ID}/{database ID}, e.g.
Expand All @@ -189,4 +163,4 @@ The `response` block `latest_import_status` contains:
$ terraform import rediscloud_subscription_database.database-resource 123456/12345678
```

Note: Due to constraints in the Redis Cloud API, the `memory_limit_in_gb` cannot be set during imports as it is deprecated. If you need to set the `memory_limit_in_gb` attribute, you will need to create a new database resource. It is recommended to use the `dataset_size_in_gb` attribute instead.
Note: Due to constraints in the Redis Cloud API, the `memory_limit_in_gb` cannot be set during imports as it is deprecated. If you need to set the `memory_limit_in_gb` attribute, you will need to create a new database resource. It is recommended to use the `dataset_size_in_gb` attribute instead.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/RedisLabs/terraform-provider-rediscloud
go 1.22.4

require (
github.com/RedisLabs/rediscloud-go-api v0.20.1
github.com/RedisLabs/rediscloud-go-api v0.21.0
github.com/bflad/tfproviderlint v0.30.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/RedisLabs/rediscloud-go-api v0.20.1 h1:imYAb7qi7XCHHQ8IeBo4CUr8KWjiZ8Njj0P84YmqhSI=
github.com/RedisLabs/rediscloud-go-api v0.20.1/go.mod h1:3/oVb71rv2OstFRYEc65QCIbfwnJTgZeQhtPCcdHook=
github.com/RedisLabs/rediscloud-go-api v0.21.0 h1:4f5fz7cfP8zRtmzR4sW7dwmLnxgKgUInxTBMGmc6gFE=
github.com/RedisLabs/rediscloud-go-api v0.21.0/go.mod h1:3/oVb71rv2OstFRYEc65QCIbfwnJTgZeQhtPCcdHook=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down
5 changes: 4 additions & 1 deletion provider/datasource_rediscloud_database_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ func TestAccDataSourceRedisCloudDatabaseModules_basic(t *testing.T) {
"name": "RediSearch",
}),
resource.TestCheckTypeSetElemNestedAttrs("data.rediscloud_database_modules.foo", "modules.*", map[string]string{
"name": "RedisGraph",
"name": "RedisJSON",
}),
resource.TestCheckTypeSetElemNestedAttrs("data.rediscloud_database_modules.foo", "modules.*", map[string]string{
"name": "RedisTimeSeries",
}),
),
},
Expand Down
7 changes: 0 additions & 7 deletions provider/rediscloud_active_active_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,6 @@ func TestAccResourceRedisCloudActiveActiveDatabase_CRUDI(t *testing.T) {
"override_region.0.override_global_alert.0.value",
"override_region.0.override_global_data_persistence",
"override_region.0.override_global_password",
"override_region.0.latest_backup_status.#",
"override_region.0.latest_backup_status.0.%",
"override_region.0.latest_backup_status.0.error.#",
"override_region.0.latest_backup_status.0.error.0.%",
"override_region.0.latest_backup_status.0.error.0.description",
"override_region.0.latest_backup_status.0.error.0.status",
"override_region.0.latest_backup_status.0.error.0.type",
},
},
},
Expand Down
Loading

0 comments on commit 2fc3d1f

Please sign in to comment.