{
  "id": "get-started",
  "title": "Get started with Terraform",
  "url": "https://redis.io/docs/latest/integrate/terraform-provider-for-redis-cloud/get-started/",
  "summary": "Shows how to install the Redis Cloud provider and create a subscription.",
  "tags": [
    "docs",
    "integrate",
    "rc"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "1079fefb25ef45c8fa66ad75ee40fe344d9332b9554ee7ff67f8c6f53d607633",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Here, you'll learn how to use the [Redis Cloud Terraform Provider]() to create a subscription and a database."
    },
    {
      "id": "prerequisites",
      "title": "Prerequisites",
      "role": "content",
      "text": "1. [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli).\n\n1. [Create a Redis Cloud account]() if you do not have one already.\n\n1. [Enable the Redis Cloud API]().\n\n1. Get your Redis Cloud [API keys](). Set them to the following environment variables:\n\n    - Set `REDISCLOUD_ACCESS_KEY` to your API account key.\n    - Set `REDISCLOUD_SECRET_KEY` to your API user key.\n\n1. Set a [payment method]()."
    },
    {
      "id": "install-the-redis-cloud-provider",
      "title": "Install the Redis Cloud provider",
      "role": "setup",
      "text": "1. Create a file to contain the Terraform configuration called `main.tf`.\n\n1. Go to the [Redis Cloud Terraform Registry](https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/).\n\n1. Select **Use Provider** and copy the Terraform code located there. Paste the code into `main.tf` and save the file.\n\n   [code example]\n   \n1. Run `terraform init`."
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform",
      "title": "Create a Redis Cloud subscription with Terraform",
      "role": "content",
      "text": "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](https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs) for more info about the resources and data sources you can use as part of the Redis Cloud provider.\n\nThe steps in this section show you how to plan and create a Redis Cloud Pro subscription with one database.\n\n1. Use the [`rediscloud_payment_method`](https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/data-sources/rediscloud_payment_method) data source to get the payment method ID.\n\n    [code example]\n   \n   Example:\n\n   [code example]\n   \n1. Define a [`rediscloud_subscription`](https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_subscription) resource to create the subscription.\n\n    [code example]\n\n   Example:\n\n   [code example]\n\n1. Define a [`rediscloud_subscription_database`](https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs/resources/rediscloud_subscription_database) resource to create a database.\n\n    [code example]\n   \n   Example:\n\n   [code example]\n\n2. Run `terraform plan` to check for any syntax errors.\n\n    [code example]\n\n3. Run `terraform apply` to apply the changes and enter `yes` to confirm when prompted.\n\n    This will take some time. You will see messages in your terminal while the subscription and database are being created:\n\n   [code example]\n\n   When provisioning is complete, you will see a message in your terminal:   \n\n   [code example]\n\n   View the [Redis Cloud console](https://cloud.redis.io/) to verify your subscription and database creation.\n\n4. If you want to remove these sample resources, run `terraform destroy`."
    },
    {
      "id": "more-info",
      "title": "More info",
      "role": "content",
      "text": "- [Redis Cloud Terraform Registry](https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs)\n- [Terraform documentation](https://developer.hashicorp.com/terraform/docs)\n- [Terraform configuration syntax](https://developer.hashicorp.com/terraform/language/syntax/configuration)"
    }
  ],
  "examples": [
    {
      "id": "install-the-redis-cloud-provider-ex0",
      "language": "text",
      "code": "provider \"rediscloud\" {\n   }\n\n   # Example resource configuration\n   resource \"rediscloud_subscription\" \"example\" {\n      # ...\n   }",
      "section_id": "install-the-redis-cloud-provider"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex0",
      "language": "text",
      "code": "# Get credit card details\n    data \"rediscloud_payment_method\" \"card\" {\n        card_type = \"<Card type>\"\n        last_four_numbers = \"<Last four numbers on the card>\"\n    }",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex1",
      "language": "text",
      "code": "data \"rediscloud_payment_method\" \"card\" {\n      card_type = \"Visa\"\n      last_four_numbers = \"5625\"\n   }",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex2",
      "language": "text",
      "code": "# Create a subscription\n    resource \"rediscloud_subscription\" \"subscription-resource\" {\n            name = \"subscription-name\"\n            payment_method_id = data.rediscloud_payment_method.card.id # If you want to pay with a marketplace account, replace this line with payment_method = 'marketplace'.\n            memory_storage = \"ram\"\n\n            # Specify the cloud provider information here\n            cloud_provider {\n                    provider = \"<Cloud provider>\"\n                    region {\n                            region = \"<region>\"\n                            networking_deployment_cidr = \"<CIDR>\"\n                    }\n            }\n\n            #Define the average database specification for databases in the subscription\n            creation_plan {\n                    memory_limit_in_gb = 2\n                    quantity = 1\n                    replication = true\n                    throughput_measurement_by = \"operations-per-second\"\n                    throughput_measurement_value = 20000\n            }\n    }",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex3",
      "language": "text",
      "code": "resource \"rediscloud_subscription\" \"subscription-resource\" {\n        name = \"redis-docs-sub\"\n        payment_method_id = data.rediscloud_payment_method.card.id # If you want to pay with a marketplace account, replace this line with payment_method = 'marketplace'.\n        memory_storage = \"ram\"\n\n        cloud_provider {\n                provider = \"GCP\"\n                region {\n                        region = \"us-west1\"\n                        networking_deployment_cidr = \"192.168.0.0/24\"\n                }\n        }\n\n        creation_plan {\n                memory_limit_in_gb = 2\n                quantity = 1\n                replication = true\n                throughput_measurement_by = \"operations-per-second\"\n                throughput_measurement_value = 20000\n                modules = [\"RedisJSON\"]\n        }\n   }",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex4",
      "language": "text",
      "code": "# Create a Database\n    resource \"rediscloud_subscription_database\" \"database-resource\" {\n        subscription_id = rediscloud_subscription.subscription-resource.id\n        name = \"database-name\"\n        memory_limit_in_gb = 2\n        data_persistence = \"aof-every-write\"\n        throughput_measurement_by = \"operations-per-second\"\n        throughput_measurement_value = 20000\n        replication = true\n\n        alert {\n        name = \"dataset-size\"\n        value = 40\n        }\n        depends_on = [rediscloud_subscription.subscription-resource]\n\n    }",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex5",
      "language": "text",
      "code": "resource \"rediscloud_subscription_database\" \"database-resource\" {\n       subscription_id = rediscloud_subscription.subscription-resource.id\n       name = \"redis-docs-db\"\n       memory_limit_in_gb = 2\n       data_persistence = \"aof-every-write\"\n       throughput_measurement_by = \"operations-per-second\"\n       throughput_measurement_value = 20000\n       replication = true\n\n       modules = [\n       {\n            name = \"RedisJSON\"\n       }\n       ]\n\n       alert {\n       name = \"dataset-size\"\n       value = 40\n       }\n      depends_on = [rediscloud_subscription.subscription-resource]\n\n   }",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex6",
      "language": "sh",
      "code": "$ terraform plan\n    data.rediscloud_payment_method.card: Reading...\n    data.rediscloud_payment_method.card: Read complete after 1s [id=8859]\n\n    Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following\n    symbols:\n    + create\n\n    Terraform will perform the following actions:\n\n        # rediscloud_subscription.subscription-resource will be created\n        + resource \"rediscloud_subscription\" \"subscription-resource\" {\n            [...]\n        }\n\n        # rediscloud_subscription_database.database-resource will be created\n        + resource \"rediscloud_subscription_database\" \"database-resource\" {\n            [...]\n        }\n    \n    Plan: 2 to add, 0 to change, 0 to destroy.",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex7",
      "language": "text",
      "code": "rediscloud_subscription.subscription-resource: Creating...\n   rediscloud_subscription.subscription-resource: Still creating... [10s elapsed]\n   rediscloud_subscription.subscription-resource: Still creating... [20s elapsed]\n   rediscloud_subscription.subscription-resource: Still creating... [30s elapsed]",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    },
    {
      "id": "create-a-redis-cloud-subscription-with-terraform-ex8",
      "language": "text",
      "code": "Apply complete! Resources: 2 added, 0 changed, 0 destroyed.",
      "section_id": "create-a-redis-cloud-subscription-with-terraform"
    }
  ]
}
