Skip to content

Commit

Permalink
Renamed/deprecated flexible datasources and resources (subscriptions …
Browse files Browse the repository at this point in the history
…and databases) (#493)

* Renamed/deprecated flexible datasources and resources (subscriptions and databases)

* Doc fixes

* Updated documentation
  • Loading branch information
JohnSharpe committed May 13, 2024
1 parent d6266de commit 71b9589
Show file tree
Hide file tree
Showing 38 changed files with 4,905 additions and 881 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/terraform_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
}
}
EOT
echo 'resource "rediscloud_subscription" "example" {}' > example.tf
echo 'resource "rediscloud_flexible_subscription" "example" {}' > example.tf
terraform init -plugin-dir terraform-plugin-dir
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure'
name: terraform providers schema
Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/rediscloud_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: |-

# Data Source: rediscloud_database

!> **WARNING:** This resource is deprecated and will be removed in the next major version. Switch to `rediscloud_flexible_database` or `rediscloud_active_active_database` (incoming)

The Database data source allows access to the details of an existing database within your Redis Enterprise Cloud account.

## Example Usage
Expand Down
66 changes: 66 additions & 0 deletions docs/data-sources/rediscloud_flexible_database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_flexible_database"
description: |-
Database data source in the Redis Cloud Terraform provider.
---

# Data Source: rediscloud_flexible_database

The Flexible Database data source allows access to the details of an existing database within your Redis Enterprise Cloud account.

## Example Usage

The following example shows how to locate a single database within a Subscription. This example assumes the subscription only contains a single database.

```hcl-terraform
data "rediscloud_flexible_database" "example" {
subscription_id = "1234"
}
```

The following example shows how to use the name to locate a single database within a subscription that has multiple databases.

```hcl-terraform
data "rediscloud_flexible_database" "example" {
subscription_id = "1234"
name = "first-database"
}
```


## Argument Reference

* `subscription_id` - (Required) ID of the subscription that the database belongs to
* `name` - (Optional) The name of the database to filter returned databases
* `protocol` - (Optional) The protocol of the database to filter returned databases
* `region` - (Optional) The region of the database to filter returned databases

## Attributes Reference

* `name` - The name of the database
* `protocol` - The protocol of the database.
* `memory_limit_in_gb` - The maximum memory usage for the database.
* `support_oss_cluster_api` - Supports the Redis open-source (OSS) Cluster API.
* `resp_version` - Either `resp2` or `resp3`. Database's RESP version.
* `replica_of` - The set of Redis database URIs, in the format `redis://user:password@host:port`, that this
database will be a replica of.
* `alert` - Set of alerts to enable on the database, documented below.
* `data_persistence` - The rate of database data persistence (in persistent storage).
* `data_eviction` - The data items eviction policy.
* `password` - The password used to access the database - not present on `memcached` protocol databases.
* `replication` - Database replication.
* `throughput_measurement_by` - The throughput measurement method.
* `throughput_measurement_value` - The throughput value.
* `hashing_policy` - The list of regular expression rules the database is sharded by. See
[the documentation on clustering](https://docs.redislabs.com/latest/rc/concepts/clustering/) for more information on the
hashing policy.
* `public_endpoint` - Public endpoint to access the database
* `private_endpoint` - Private endpoint to access the database
* `enable_tls` - Enable TLS for database, default is `false`
* `enable_default_user` - When `true` enables connecting to the database with the default user. Default `true`.

The `alert` block supports:

* `name` - The alert name
* `value` - The alert value
58 changes: 58 additions & 0 deletions docs/data-sources/rediscloud_flexible_subscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_flexible_subscription"
description: |-
Flexible Subscription data source in the Redis Cloud Terraform provider.
---

# Data Source: rediscloud_flexible_subscription

The Flexible Subscription data source allows access to the details of an existing flexible subscription within your Redis Enterprise Cloud account.

## Example Usage

The following example shows how to use the name attribute to locate a flexible subscription within your Redis Enterprise Cloud account.

```hcl
data "rediscloud_flexible_subscription" "example" {
name = "My Example Subscription"
}
output "rediscloud_flexible_subscription" {
value = data.rediscloud_flexible_subscription.example.id
}
```

## Argument Reference

* `name` - (Optional) The name of the subscription to filter returned subscriptions

## Attributes Reference

`id` is set to the ID of the found subscription.

* `payment_method_id` - A valid payment method pre-defined in the current account
* `memory_storage` - Memory storage preference: either ‘ram’ or a combination of 'ram-and-flash’
* `cloud_provider` - A cloud provider object, documented below
* `number_of_databases` - The number of databases that are linked to this subscription.
* `status` - Current status of the subscription

The `cloud_provider` block supports:

* `provider` - The cloud provider to use with the subscription, (either `AWS` or `GCP`)
* `cloud_account_id` - Cloud account identifier, (A Cloud Account Id = 1 implies using Redis Labs internal cloud account)
* `region` - Cloud networking details, per region (single region or multiple regions for Active-Active cluster only), documented below

The cloud_provider `region` block supports:

* `region` - Deployment region as defined by cloud provider
* `multiple_availability_zones` - Support deployment on multiple availability zones within the selected region
* `networking_vpc_id` - The ID of the VPC where the Redis Cloud subscription is deployed.
* `preferred_availability_zones` - List of availability zones used

* `networks` - List of generated network configuration

The `networks` block has these attributes:

* `networking_subnet_id` - The subnet that the subscription deploys into
* `networking_deployment_cidr` - Deployment CIDR mask for the generated
* `networking_vpc_id` - VPC id for the generated network
2 changes: 1 addition & 1 deletion docs/data-sources/rediscloud_payment_method.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data "rediscloud_payment_method" "card" {
card_type = "Visa"
}
resource "rediscloud_subscription" "example" {
resource "rediscloud_flexible_subscription" "example" {
name = "My Test Subscription"
payment_method_id = data.rediscloud_payment_method.card.id
Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/rediscloud_subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: |-

# Data Source: rediscloud_subscription

!> **WARNING:** This resource is deprecated and will be removed in the next major version. Switch to `rediscloud_flexible_subscription` or `rediscloud_active_active_subscription` (incoming)

The Subscription data source allows access to the details of an existing subscription within your Redis Enterprise Cloud account.

## Example Usage
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ provider "rediscloud" {
}
# Example resource configuration
resource "rediscloud_subscription" "example" {
resource "rediscloud_flexible_subscription" "example" {
# ...
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/rediscloud_acl_role.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ resource "rediscloud_acl_role" "role-resource" {
rule {
name = rediscloud_acl_rule.rule-resource.name
database {
subscription = rediscloud_subscription.subscription-resource.id
database = rediscloud_subscription_database.database-resource.db_id
subscription = rediscloud_flexible_subscription.subscription-resource.id
database = rediscloud_flexible_database.database-resource.db_id
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/rediscloud_cloud_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "rediscloud_cloud_account" "example" {
sign_in_login_url = "https://1234567890.signin.aws.amazon.com/console"
}
resource "rediscloud_subscription" "example" {
resource "rediscloud_flexible_subscription" "example" {
name = "My Example Subscription"
payment_method_id = data.rediscloud_payment_method.card.id
memory_storage = "ram"
Expand Down
152 changes: 152 additions & 0 deletions docs/resources/rediscloud_flexible_database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_flexible_database"
description: |-
Database resource in the Terraform provider Redis Cloud.
---

# Resource: rediscloud_flexible_database

Creates a Database within a specified Flexible Subscription in your Redis Enterprise Cloud Account.

## Example Usage

```hcl
data "rediscloud_payment_method" "card" {
card_type = "Visa"
}
resource "rediscloud_flexible_subscription" "subscription-resource" {
name = "subscription-name"
payment_method = "credit-card"
payment_method_id = data.rediscloud_payment_method.card.id
memory_storage = "ram"
cloud_provider {
provider = data.rediscloud_cloud_account.account.provider_type
region {
region = "eu-west-1"
multiple_availability_zones = true
networking_deployment_cidr = "10.0.0.0/24"
preferred_availability_zones = ["euw1-az1", "euw1-az2", "euw1-az3"]
}
}
// This block needs to be defined for provisioning a new subscription.
// This allows creation of a well-optimized hardware specification for databases in the cluster
creation_plan {
memory_limit_in_gb = 15
quantity = 1
replication=true
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 20000
modules = ["RedisJSON"]
}
}
// The primary database to provision
resource "rediscloud_flexible_database" "database-resource" {
subscription_id = rediscloud_flexible_subscription.subscription-resource.id
name = "database-name"
memory_limit_in_gb = 15
data_persistence = "aof-every-write"
throughput_measurement_by = "operations-per-second"
throughput_measurement_value = 20000
replication = true
modules = [
{
name = "RedisJSON"
}
]
alert {
name = "dataset-size"
value = 40
}
}
```

## Argument Reference

The following arguments are supported:

* `subscription_id` - (Required) The ID of the subscription to create the database in. **Modifying this attribute will force creation of a new resource.**
* `name` - (Required) A meaningful name to identify the database
* `throughput_measurement_by` - (Required) Throughput measurement method, (either ‘number-of-shards’ or ‘operations-per-second’)
* `throughput_measurement_value` - (Required) Throughput value (as applies to selected measurement method)
* `memory_limit_in_gb` - (Required) Maximum memory usage for this specific database
* `protocol` - (Optional) The protocol that will be used to access the database, (either ‘redis’ or ‘memcached’) Default: ‘redis’. **Modifying this attribute will force creation of a new resource.**
* `support_oss_cluster_api` - (Optional) Support Redis open-source (OSS) Cluster API. Default: ‘false’
* `resp_version` - (Optional) Either `resp2` or `resp3`. Database's RESP version. Must be compatible with the Redis version.
* `external_endpoint_for_oss_cluster_api` - (Optional) Should use the external endpoint for open-source (OSS) Cluster API.
Can only be enabled if OSS Cluster API support is enabled. Default: 'false'
* `client_ssl_certificate` - (Optional) SSL certificate to authenticate user connections
* `periodic_backup_path` - (Optional) Path that will be used to store database backup files. **Deprecated: Use `remote_backup` block instead**
* `replica_of` - (Optional) Set of Redis database URIs, in the format `redis://user:password@host:port`, that this
database will be a replica of. If the URI provided is Redis Labs Cloud instance, only host and port should be provided.
Cannot be enabled when `support_oss_cluster_api` is enabled.
* `modules` - (Optional) A list of modules objects, documented below. **Modifying this attribute will force creation of a new resource.**
* `alert` - (Optional) A block defining Redis database alert, documented below, can be specified multiple times
* `data_persistence` - (Optional) Rate of database's storage data persistence (either: 'none', 'aof-every-1-second', 'aof-every-write', 'snapshot-every-1-hour', 'snapshot-every-6-hours' or 'snapshot-every-12-hours'). Default: ‘none’
* `data_eviction` - (Optional) The data items eviction policy (either: 'allkeys-lru', 'allkeys-lfu', 'allkeys-random', 'volatile-lru', 'volatile-lfu', 'volatile-random', 'volatile-ttl' or 'noeviction'). Default: 'volatile-lru'
* `password` - (Optional) Password to access the database. If omitted, a random 32 character long alphanumeric password will be automatically generated
* `replication` - (Optional) Databases replication. Default: ‘true’
* `average_item_size_in_bytes` - (Optional) Relevant only to ram-and-flash clusters. Estimated average size (measured in bytes)
of the items stored in the database. Default: 1000
* `source_ips` - (Optional) List of source IP addresses or subnet masks. If specified, Redis clients will be able to connect to this database only from within the specified source IP addresses ranges (example: [‘192.168.10.0/32’, ‘192.168.12.0/24’])
* `hashing_policy` - (Optional) List of regular expression rules to shard the database by. See
[the documentation on clustering](https://docs.redislabs.com/latest/rc/concepts/clustering/) for more information on the
hashing policy. This cannot be set when `support_oss_cluster_api` is set to true.
* `enable_tls` - (Optional) Use TLS for authentication. Default: ‘false’
* `port` - (Optional) TCP port on which the database is available - must be between 10000 and 19999. **Modifying this attribute will force creation of a new resource.**
* `remote_backup` (Optional) Specifies the backup options for the database, documented below
* `enable_default_user` (Optional) When `true` enables connecting to the database with the default user. Default `true`.

The `alert` block supports:

* `name` (Required) - Alert name. (either: 'dataset-size', 'datasets-size', 'throughput-higher-than', 'throughput-lower-than', 'latency', 'syncsource-error', 'syncsource-lag' or 'connections-limit')
* `value` (Required) - Alert value

The `modules` list supports:

* `name` (Required) - Name of the Redis database module to enable. **Modifying this attribute will force creation of a new resource.**

Example:

```hcl
modules = [
{
"name": "RedisJSON"
},
{
"name": "RedisBloom"
}
]
```

The `remote_backup` block supports:

* `interval` (Required) - Defines the interval between backups. Should be in the following format 'every-x-hours'. x is one of [24,12,6,4,2,1]. For example: 'every-4-hours'
* `time_utc` (Optional) - Defines the hour automatic backups are made - only applicable when the interval is `every-12-hours` or `every-24-hours`. For example: '14:00'
* `storage_type` (Required) - Defines the provider of the storage location
* `storage_path` (Required) - Defines a URI representing the backup storage location

### Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:

* `create` - (Defaults to 30 mins) Used when creating the database
* `update` - (Defaults to 30 mins) Used when updating the database
* `delete` - (Defaults to 10 mins) Used when destroying the database

## Attribute reference

* `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` - An object containing the JSON-formatted response detailing the latest backup status (or an error if the lookup failed).
* `latest_import_status` - An object containing the JSON-formatted response detailing the latest import status (or an error if the lookup failed).

## Import
`rediscloud_flexible_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.

```
$ terraform import rediscloud_flexible_database.database-resource 123456/12345678
```
Loading

0 comments on commit 71b9589

Please sign in to comment.