Here, you’ll learn how to use the Redis Cloud Terraform Provider to create a subscription and a database.


  1. Install Terraform.

  2. Create a Redis Cloud account if you do not have one already.

  3. Enable the Redis Cloud API.

  4. Get your Redis Cloud API keys. Set them to the following environment variables:

    • Set REDISCLOUD_ACCESS_KEY to your API account key.
    • Set REDISCLOUD_SECRET_KEY to your API user key.
  5. Set a payment method.

Install the Redis Cloud provider

  1. Create a file to contain the Terraform configuration called

  2. Go to the Redis Cloud Terraform Registry.

  3. Select Use Provider and copy the Terraform code located there. Paste the code into and save the file.

  4. Run terraform init.

Create a Redis Cloud subscription with Terraform

In your Terraform configuration file, you can add resources and data sources to plan and create subscriptions and databases. See the Redis Cloud Terraform Registry documentation for more info about the resources and data sources you can use as part of the Redis Cloud provider.

The steps in this section show you how to plan and create a flexible subscription with one database.

  1. Use the rediscloud_payment_method data source to get the payment method ID.

    # Get credit card details
    data "rediscloud_payment_method" "card" {
        card_type = "<Card type>"
        last_four_numbers = "<Last four numbers on the card>"
  2. Define a rediscloud_subscription resource to create the subscription.

    # Create a subscription
    resource "rediscloud_subscription" "subscription-resource" {
            name = "subscription-name"
            payment_method_id =
            memory_storage = "ram"
            # Specify the cloud provider information here
            cloud_provider {
                    provider = "<Cloud provider>"
                    region {
                            region = "<region>"
                            networking_deployment_cidr = "<CIDR>"
            #Define the average database specification for databases in the subscription
            creation_plan {
                    memory_limit_in_gb = 2
                    quantity = 1
                    replication = true
                    throughput_measurement_by = "operations-per-second"
                    throughput_measurement_value = 20000
                    modules = ["RedisJSON"]
  3. Define a rediscloud_subscription_database resource to create a database.

    # Create a Database
    resource "rediscloud_subscription_database" "database-resource" {
        subscription_id =
        name = "database-name"
        memory_limit_in_gb = 2
        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
        depends_on = [rediscloud_subscription.subscription-resource]
  4. Run terraform plan to check for any syntax errors.

    $ terraform plan
    data.rediscloud_payment_method.card: Reading...
    data.rediscloud_payment_method.card: Read complete after 1s [id=8859]
    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
    + create
    Terraform will perform the following actions:
        # rediscloud_subscription.subscription-resource will be created
        + resource "rediscloud_subscription" "subscription-resource" {
        # rediscloud_subscription_database.database-resource will be created
        + resource "rediscloud_subscription_database" "database-resource" {
    Plan: 2 to add, 0 to change, 0 to destroy.
  5. Run terraform apply to apply the changes and enter yes to confirm when prompted.

    This will take some time. You will be able to see your subscription being created through the admin console.

  6. If you want to remove these sample resources, run terraform destroy.

More info