Skip to main content
Terraform is an infrastructure-as-code tool that enables you to safely and predictably provision and manage infrastructure. This page explains how to configure Terraform to manage your or .

Prerequisites

To follow the steps on this page:
  • Create a target with the Real-time analytics capability enabled.

    You need your connection details. This procedure also works for .

Configure Terraform

Configure Terraform based on your deployment type:
You use the Terraform provider to manage s:
  1. Generate client credentials for programmatic use
    1. In , click Projects and save your Project ID, then click Project settings.
    2. Click Create credentials, then save Public key and Secret key.
  2. Configure the Terraform provider
    1. Create a main.tf configuration file with at least the following content. Change x.y.z to the latest version of the provider.
      terraform {
        required_providers {
          timescale = {
            source  = "timescale/timescale"
            version = "x.y.z"
          }
        }
      }
      
      # Authenticate using client credentials generated in Tiger Console.
      # When required, these credentials will change to a short-lived JWT to do the calls.
      provider "timescale" {
       project_id = var.ts_project_id
       access_key = var.ts_access_key
       secret_key = var.ts_secret_key
      }
      
      variable "ts_project_id" {
       type = string
      }
      
      variable "ts_access_key" {
       type = string
      }
      
      variable "ts_secret_key" {
       type = string
      }
      
    2. Create a terraform.tfvars file in the same directory as your main.tf to pass in the variable values:
      export TF_VAR_ts_project_id="<your-timescale-project-id>"
      export TF_VAR_ts_access_key="<your-timescale-access-key>"
      export TF_VAR_ts_secret_key="<your-timescale-secret-key>"
      
  3. Add your resources Add your s or connections to the main.tf configuration file. For example:
    resource "timescale_service" "test" {
      name              = "test-service"
      milli_cpu         = 500
      memory_gb         = 2
      region_code       = "us-east-1"
      enable_ha_replica = false
    
      timeouts = {
        create = "30m"
      }
    }
    
    resource "timescale_vpc" "vpc" {
      cidr         = "10.10.0.0/16"
      name         = "test-vpc"
      region_code  = "us-east-1"
    }
    
You can now manage your resources with Terraform. See more about available resources and data sources.