### timescale_service Resource Example Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/service.md This example demonstrates how to configure the timescale_service resource, including setting up the provider and defining service properties like name, CPU, memory, and region. It also shows how to create a read replica. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } variable "ts_access_key" { type = string } variable "ts_secret_key" { type = string sensitive = true } variable "ts_project_id" { type = string } provider "timescale" { access_key = var.ts_access_key secret_key = var.ts_secret_key project_id = var.ts_project_id } resource "timescale_service" "test" { name = "test" milli_cpu = 1000 memory_gb = 4 region_code = "us-east-1" } # Read replica resource "timescale_service" "read_replica" { read_replica_source = timescale_service.test.id } ``` -------------------------------- ### Configure Timescale Provider and Fetch VPCs Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/data-sources/vpcs.md This example demonstrates how to configure the Timescale Terraform provider with access keys, secret keys, and project ID. It then uses the `timescale_vpcs` data source to fetch VPC information and outputs the result. This setup is crucial for interacting with Timescale resources via Terraform. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } variable "ts_access_key" { type = string } variable "ts_secret_key" { type = string sensitive = true } variable "ts_project_id" { type = string } provider "timescale" { access_key = var.ts_access_key secret_key = var.ts_secret_key project_id = var.ts_project_id } data "timescale_vpcs" "vpcs" { } output "vpcs_list" { value = data.timescale_vpcs.vpcs } ``` -------------------------------- ### Build and Prepare Timescale Terraform Provider Source: https://github.com/timescale/terraform-provider-timescale/blob/main/README.md This command automates formatting, linting, installation, and generation of necessary files for the Timescale Terraform provider. It's a core command for development and documentation updates. ```shell make ``` -------------------------------- ### Timescale Provider Configuration and VPC Resource Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/vpcs.md Configures the Timescale Terraform provider with authentication details and defines a Timescale VPC resource. This example shows how to set up the provider using variables for project ID, access key, and secret key, and then creates a VPC with a specified CIDR, name, and region. ```Terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } 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 sensitive = true } resource "timescale_vpcs" "ts-test" { cidr = "10.0.0.0/24" name = "tf-test" region_code = "us-east-1" } ``` -------------------------------- ### Configure Timescale Provider and Metric Exporters Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/metric_exporter.md This example demonstrates how to configure the Timescale Terraform provider and define various metric exporters, including Datadog, Prometheus, and CloudWatch, with different authentication methods. It also shows how to attach a metric exporter to a Timescale service. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } 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 sensitive = true } resource "timescale_metric_exporter" "my_datadog_exporter" { name = "Datadog Exporter from TF" region = "us-east-1" datadog = { api_key = "your_datadog_api_key_here" site = "datadoghq.com" } } resource "timescale_metric_exporter" "my_prometheus_exporter" { name = "Prometheus Exporter from TF" region = "us-east-1" prometheus = { username = "prom_user" password = "a_very_secure_password" } } resource "timescale_metric_exporter" "my_cloudwatch_exporter_with_role" { name = "CloudWatch Exporter via IAM Role from TF" region = "us-east-1" cloudwatch = { region = "us-east-1" role_arn = "arn:aws:iam::123456789012:role/MyMetricsExporterRole" log_group_name = "/myapplication/metrics" log_stream_name = "exporter-stream-role" namespace = "MyApplication/CustomMetrics" } } resource "timescale_metric_exporter" "my_cloudwatch_exporter_with_keys" { name = "CloudWatch Exporter via Static Keys" region = "us-east-1" cloudwatch = { region = "us-east-1" access_key = "your_access_key_" secret_key = "your_secret_keyxxxxxxxxxxxxxxxxxxxxxxxxx" log_group_name = "/anotherapplication/metrics" log_stream_name = "exporter-stream-keys" namespace = "AnotherApplication/CustomMetrics" } } resource "timescale_service" "metric_exporter_test" { name = "metric_exporter_test" milli_cpu = 1000 memory_gb = 4 region_code = "us-east-1" metric_exporter_id = timescale_metric_exporter.my_cloudwatch_exporter_with_keys.id } ``` -------------------------------- ### Set Timescale Credentials in tfvars Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/index.md This file provides example values for the Timescale project ID, access key, and secret key, intended to be used with Terraform's variable files. Users must replace placeholder values with their actual credentials. ```hcl ts_project_id="WWWWWWWWWW" ts_access_key="XXXXXXXXXXXXXXXXXXXXXXXXXX" ts_secret_key="YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" ``` -------------------------------- ### Run Timescale Terraform Provider Acceptance Tests Source: https://github.com/timescale/terraform-provider-timescale/blob/main/README.md This command executes the full suite of acceptance tests for the Timescale Terraform provider. It is recommended to run `make` first to ensure the provider is up-to-date and to avoid potential issues during testing. ```shell make testacc ``` -------------------------------- ### Timescale Provider Configuration and Product Data Source Usage Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/data-sources/products.md This snippet demonstrates how to configure the Timescale Terraform provider and use the `timescale_products` data source to fetch available products. It includes setting required providers, defining variables for credentials and project ID, configuring the provider, and outputting the retrieved product information. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } variable "ts_access_key" { type = string } variable "ts_secret_key" { type = string sensitive = true } variable "ts_project_id" { type = string } provider "timescale" { access_key = var.ts_access_key secret_key = var.ts_secret_key project_id = var.ts_project_id } data "timescale_products" "products" { } output "products_list" { value = data.timescale_products.products } ``` -------------------------------- ### Set Environment Variables for Acceptance Tests Source: https://github.com/timescale/terraform-provider-timescale/blob/main/README.md These shell commands export environment variables required to run the acceptance tests for the Timescale Terraform provider. They include project credentials, peer network details, and an optional API URL for testing different environments. ```shell export TF_VAR_ts_project_id= export TF_VAR_ts_access_key= export TF_VAR_ts_secret_key= export PEER_ACCOUNT_ID= export PEER_REGION= export PEER_VPC_ID= export PEER_TGW_ID= export TIMESCALE_DEV_URL= # Optional: to use different environment ``` -------------------------------- ### timescale_service Resource Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/service.md Manages a TimescaleDB Service instance, allowing configuration of CPU, memory, region, and read replicas. ```APIDOC ## CREATE timescale_service ### Description Creates a new TimescaleDB service instance with specified configurations. ### Method POST ### Endpoint /services ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (String) - Optional - The configurable name assigned to this resource. If none is provided, a default will be generated by the provider. - **milli_cpu** (Number) - Required - The amount of CPU in milli-cores to allocate to the service. - **memory_gb** (Number) - Required - The amount of memory in GB to allocate to the service. - **region_code** (String) - Required - The region code where the service will be provisioned. - **read_replica_source** (String) - Optional - If set, this database will be a read replica of the provided source database. The region must be the same as the source, or if omitted will be handled by the provider. - **connection_pooler_enabled** (Boolean) - Optional - Set connection pooler status for this service. - **environment_tag** (String) - Optional - Set environment tag for this service. - **ha_replicas** (Number) - Optional - Number of HA replicas (0, 1 or 2). Modes: 1 for 'High availability'; 2 'Highest availability'. Async replicas will be created by default if sync_replicas is not set. - **log_exporter_id** (String) - Optional - The Log Exporter ID attached to this service. WARNING: To complete the logs exporter attachment, a service restart is required. - **metric_exporter_id** (String) - Optional - The Exporter ID attached to this service. - **password** (String, Sensitive) - Optional - The Postgres password for this service. - **paused** (Boolean) - Optional - Paused status of the service. - **storage_gb** (Number, Deprecated) - Optional - Deprecated: Storage GB - **sync_replicas** (Number) - Optional - Number of synchronous replicas (0 or 1). Set to 1 to enable 'High data integrity mode' (1 Sync and 1 Async replicas). To set sync_replicas to 1, you must also set ha_replicas to 2. - **vpc_id** (Number) - Optional - The VpcID this service is tied to. - **enable_ha_replica** (Boolean, Deprecated) - Optional - Enable HA Replica (deprecated - use ha_replicas and sync_replicas instead) - **timeouts** (Object) - Optional - Configuration for operation timeouts. - **create** (String) - Optional - A string that can be parsed as a duration, e.g., "30s" or "2h45m". ### Request Example ```json { "name": "my-timescale-service", "milli_cpu": 1000, "memory_gb": 4, "region_code": "us-west-2", "connection_pooler_enabled": true, "ha_replicas": 1 } ``` ### Response #### Success Response (200) - **id** (String) - Service ID is the unique identifier for this service. - **name** (String) - The name of the service. - **hostname** (String) - The hostname for this service. - **port** (Number) - The port for this service. - **username** (String) - The Postgres user for this service. - **pooler_hostname** (String) - Hostname of the pooler of this service. - **pooler_port** (Number) - Port of the pooler of this service. - **replica_hostname** (String) - Hostname of the HA-Replica of this service. - **replica_port** (Number) - Port of the HA-Replica of this service. #### Response Example ```json { "id": "svc-abcdef1234567890", "name": "my-timescale-service", "hostname": "my-timescale-service.example.timescale.com", "port": 25060, "username": "user", "pooler_hostname": "my-timescale-service-pooler.example.timescale.com", "pooler_port": 6432, "replica_hostname": "my-timescale-service-replica.example.timescale.com", "replica_port": 25060 } ``` ### Errors - **400 Bad Request**: Invalid input parameters. - **401 Unauthorized**: Authentication failed. - **500 Internal Server Error**: Server error during provisioning. ``` -------------------------------- ### timescale_vpcs Data Source Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/data-sources/vpcs.md Fetches a list of VPCs available in the Timescale project. ```APIDOC ## GET /api/vpcs ### Description Retrieves a list of all VPCs configured for the current Timescale project. ### Method GET ### Endpoint /api/vpcs ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **vpcs** (List of Objects) - A list of VPC objects, each containing details about a VPC. - **id** (String) - The unique identifier for the VPC. - **name** (String) - The name of the VPC. - **cidr** (String) - The CIDR block assigned to the VPC. - **created** (String) - The timestamp when the VPC was created. - **updated** (String) - The timestamp when the VPC was last updated. - **project_id** (String) - The ID of the project the VPC belongs to. - **region_code** (String) - The region code where the VPC is located. - **status** (String) - The current status of the VPC (e.g., 'available', 'provisioning'). - **error_message** (String) - Any error message associated with the VPC's state. - **provisioned_id** (String) - The provisioned ID of the VPC in the underlying infrastructure. - **peering_connections** (List of Objects) - A list of peering connection details for the VPC. - **id** (Number) - The unique identifier for the peering connection. - **timescale_vpc_id** (Number) - The ID of the VPC initiating the peering connection. - **vpc_id** (String) - The ID of the peer VPC. - **provisioned_id** (String) - The provisioned ID of the peering connection. - **accepter_provisioned_id** (String) - The provisioned ID of the accepter in the peering connection. - **peering_type** (String) - The type of peering connection (e.g., 'VPC_PEERING'). - **peer_account_id** (String) - The AWS account ID of the peer VPC. - **peer_vpc_id** (String) - The ID of the peer VPC. - **peer_region_code** (String) - The region code of the peer VPC. - **peer_cidr** (String) - The CIDR block of the peer VPC. - **peer_cidr_blocks** (List of String) - A list of CIDR blocks for the peer VPC. - **peer_tgw_id** (String) - The Transit Gateway ID of the peer VPC. - **status** (String) - The status of the peering connection. - **error_message** (String) - Any error message associated with the peering connection's state. #### Response Example ```json { "vpcs": [ { "id": "vpc-1234567890abcdef0", "name": "my-timescale-vpc", "cidr": "10.0.0.0/16", "created": "2023-10-27T10:00:00Z", "updated": "2023-10-27T10:00:00Z", "project_id": "proj-abcdef1234567890", "region_code": "us-east-1", "status": "available", "error_message": null, "provisioned_id": "avpc-0123456789abcdef0", "peering_connections": [ { "id": 1, "timescale_vpc_id": 123, "vpc_id": "vpc-fedcba9876543210f", "provisioned_id": "pcx-abcdef1234567890", "accepter_provisioned_id": "pcx-0987654321fedcba", "peering_type": "VPC_PEERING", "peer_account_id": "111122223333", "peer_vpc_id": "vpc-fedcba9876543210f", "peer_region_code": "us-west-2", "peer_cidr": "172.16.0.0/16", "peer_cidr_blocks": [ "172.16.0.0/20", "172.16.16.0/20" ], "peer_tgw_id": null, "status": "active", "error_message": null } ] } ] } ``` ``` -------------------------------- ### Execute Terraform Plan with Secrets File (Shell) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md This shell command demonstrates how to apply Terraform configurations using a secrets file that contains sensitive variables like API keys. ```shell terraform plan --var-file=secrets.tfvars ``` -------------------------------- ### Create Timescale VPC Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/peering_connection.md Defines a Timescale managed VPC, specifying its CIDR block, name, and region. This resource is used as a reference point for establishing peering connections. ```terraform resource "timescale_vpcs" "ts-test" { cidr = "10.0.0.0/24" name = "tf-test" region_code = "us-east-1" } ``` -------------------------------- ### Deploy Timescale Service with HA Replica and Pooler (HCL) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/index.md This HCL code defines a Timescale service with specified CPU, memory, region, an HA replica, and enabled connection pooling. It also includes outputs for connection information of the primary host, replica, and pooler. Requires Timescale provider configuration with project ID and credentials. ```hcl terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } # Authenticate using client credentials. # They are issued through the Timescale UI. # When required, they will exchange for 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 sensitive = true } resource "timescale_service" "tf-test" { name = "tf-test" milli_cpu = 500 memory_gb = 2 region_code = "us-west-2" connection_pooler_enabled = true ha_replicas = 1 sync_replicas = 0 } ## host connection info output "host_addr" { value = timescale_service.tf-test.hostname description = "Service Host Address" } output "host_port" { value = timescale_service.tf-test.port description = "Service Host port" } ## ha-replica connection info output "replica_addr" { value = timescale_service.tf-test.replica_hostname description = "Service Replica Host Address" } output "replica_port" { value = timescale_service.tf-test.replica_port description = "Service Replica Host port" } ## pooler connection info pooler_addr { value = timescale_service.tf-test.pooler_hostname description = "Service Pooler Host Address" } pooler_port { value = timescale_service.tf-test.pooler_port description = "Service Pooler Host port" } ``` -------------------------------- ### Resource: timescale_vpcs Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/vpcs.md Manages a Timescale Cloud VPC. Import can be done using your VPCs name. ```APIDOC ## Resource: timescale_vpcs ### Description Manages a Timescale Cloud VPC. Import can be done using your VPCs name. ### Method Not Applicable (This is a Terraform resource definition) ### Endpoint Not Applicable ### Parameters #### Path Parameters Not Applicable #### Query Parameters Not Applicable #### Request Body ##### Required - **cidr** (String) - The IPv4 CIDR block - **region_code** (String) - The region for this VPC. ##### Optional - **name** (String) - VPC Name is the configurable name assigned to this vpc. If none is provided, a default will be generated by the provider. - **timeouts** (Attributes) - Optional timeouts for create operations. - **create** (String) - A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). ### Request Example ```terraform resource "timescale_vpcs" "ts-test" { cidr = "10.0.0.0/24" name = "tf-test" region_code = "us-east-1" } ``` ### Response #### Success Response (200) - **id** (Number) - The ID of this resource. - **project_id** (String) - The project ID associated with the VPC. - **provisioned_id** (String) - The provider-assigned ID of this resource. - **created** (String) - Timestamp of when the VPC was created. - **updated** (String) - Timestamp of when the VPC was last updated. - **status** (String) - The current status of the VPC provisioning. - **error_message** (String) - Any error message encountered during provisioning. #### Response Example ```json { "id": 12345, "project_id": "some-project-id", "provisioned_id": "vpc-abcdef123456", "created": "2023-10-27T10:00:00Z", "updated": "2023-10-27T10:05:00Z", "status": "available", "error_message": null } ``` ``` -------------------------------- ### Configure Local Terraform Provider Override Source: https://github.com/timescale/terraform-provider-timescale/blob/main/README.md This HCL configuration tells the Terraform CLI to use a locally built version of the Timescale provider instead of downloading it from the official registry. It requires setting the `dev_overrides` path to your local provider build. ```hcl provider_installation { dev_overrides { "registry.terraform.io/providers/timescale" = "$HOME/go/bin" } direct {} } ``` -------------------------------- ### Configure Timescale Service with HA Replica and Pooler (HCL) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md This HCL configuration defines a Timescale service with specified CPU, memory, region, an HA replica, and enabled connection pooler. It also includes outputs for connection details of the primary, replica, and pooler. ```hcl terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } # Authenticate using client credentials. # They are issued through the Timescale UI. # When required, they will exchange for 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 sensitive = true } resource "timescale_service" "tf-test" { name = "tf-test" milli_cpu = 500 memory_gb = 2 region_code = "us-west-2" connection_pooler_enabled = true ha_replicas = 1 sync_replicas = 0 } ## host connection info output "host_addr" { value = timescale_service.tf-test.hostname description = "Service Host Address" } output "host_port" { value = timescale_service.tf-test.port description = "Service Host port" } ## ha-replica connection info output "replica_addr" { value = timescale_service.tf-test.replica_hostname description = "Service Replica Host Address" } output "replica_port" { value = timescale_service.tf-test.replica_port description = "Service Replica Host port" } ## pooler connection info output "pooler_addr" { value = timescale_service.tf-test.pooler_hostname description = "Service Pooler Host Address" } output "pooler_port" { value = timescale_service.tf-test.pooler_port description = "Service Pooler Host port" } ``` -------------------------------- ### Configure Timescale and AWS Providers Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/peering_connection.md Sets up the necessary Terraform providers for Timescale and AWS, including authentication details for the Timescale provider and region configuration for AWS. This is a prerequisite for managing Timescale resources. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } aws = { source = "hashicorp/aws" version = "~> 5.0" } } } 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 sensitive = true } provider "aws" { region = "eu-central-1" } ``` -------------------------------- ### Cleanup Dangling Resources with Sweepers Source: https://github.com/timescale/terraform-provider-timescale/blob/main/README.md This command utilizes sweepers to clean up any resources that might have been left behind by failed or aborted acceptance tests. Running this before `make testacc` ensures a clean state for testing. ```shell make sweep ``` -------------------------------- ### Transit Gateway Peering Connection (Timescale to AWS) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/peering_connection.md Sets up a Transit Gateway peering connection between a Timescale VPC and an AWS Transit Gateway. This requires peer account ID, region, Transit Gateway ID, and peer CIDR blocks. It also includes dependencies on VPC peering to ensure network readiness and uses `time_sleep` to manage propagation delays. ```terraform # Wait for VPC peering to be fully established before creating TGW peering resource "time_sleep" "wait_for_vpc_peering" { depends_on = [aws_vpc_peering_connection_accepter.vpc_peer] create_duration = "120s" } # Create a test Transit Gateway in eu-central-1 resource "aws_ec2_transit_gateway" "tgw" { description = "TGW for Timescale peering" tags = { Name = "tf-test-tgw" } } # Create Transit Gateway peering with Timescale resource "timescale_peering_connection" "tgw_peer" { peer_account_id = "000000000000" peer_region_code = "eu-central-1" peer_tgw_id = aws_ec2_transit_gateway.tgw.id peer_cidr_blocks = ["16.0.0.0/24", "16.1.0.0/24"] # Required for TGW peering. timescale_vpc_id = timescale_vpcs.ts-test.id # We need to wait for previous peering to be completed because we are using the same Timescale VPC for both peerings depends_on = [time_sleep.wait_for_vpc_peering] } # Wait for TGW peering attachment to propagate to AWS resource "time_sleep" "wait_for_tgw_attachment" { depends_on = [timescale_peering_connection.tgw_peer] create_duration = "120s" } # Accept the Transit Gateway attachment resource "aws_ec2_transit_gateway_peering_attachment_accepter" "tgw_peer" { transit_gateway_attachment_id = timescale_peering_connection.tgw_peer.accepter_provisioned_id depends_on = [time_sleep.wait_for_tgw_attachment] } ``` -------------------------------- ### Provide Timescale Credentials (HCL) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md This HCL snippet provides the actual values for the Timescale project ID, access key, and secret key, typically stored in a separate .tfvars file for security. ```hcl ts_project_id="WWWWWWWWWW" access_key="XXXXXXXXXXXXXXXXXXXXXXXXXX" secret_key="YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" ``` -------------------------------- ### timescale_service Data Source Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/data-sources/service.md Service data source. This data source is used to retrieve information about a TimescaleDB service. ```APIDOC ## timescale_service Data Source ### Description Service data source. This data source is used to retrieve information about a TimescaleDB service. ### Method GET ### Endpoint /api/v1/services/{id} ### Parameters #### Path Parameters - **id** (String) - Required - Service ID is the unique identifier for this service. #### Query Parameters - **environment_tag** (String) - Optional - Environment tag for this service. - **vpc_id** (Number) - Optional - VPC ID this service is linked to. ### Response #### Success Response (200) - **id** (String) - Service ID. - **created** (String) - Created is the time this service was created. - **name** (String) - Service Name is the configurable name assigned to this resource. - **region_code** (String) - Region Code is the physical data center where this service is located. - **resources** (Attributes List) - List of resources associated with the service. - **id** (String) - Resource ID. - **spec** (Attributes) - Specification of the resource. - **enable_ha_replica** (Boolean) - EnableHAReplica defines if a replica will be provisioned for this service (deprecated). - **ha_replicas** (Number) - Number of HA replicas (0, 1 or 2). - **memory_gb** (Number) - MemoryGB is the memory allocated for this service. - **milli_cpu** (Number) - MilliCPU is the cpu allocated for this service. - **sync_replicas** (Number) - Number of synchronous replicas (0-1). - **spec** (Attributes) - Specification of the service. - **hostname** (String) - Hostname is the hostname of this service. - **pooler_hostname** (String) - Hostname of the pooler of this service. - **pooler_port** (Number) - Port of the pooler of this service. - **port** (Number) - Port is the port assigned to this service. - **replica_hostname** (String) - Hostname of the HA-Replica of this service. - **replica_port** (Number) - Port of the HA-Replica of this service. - **username** (String) - Username is the Postgres username. #### Response Example { "id": "service-123", "created": "2023-10-27T10:00:00Z", "name": "my-timescaledb-service", "region_code": "us-east-1", "resources": [ { "id": "resource-abc", "spec": { "enable_ha_replica": false, "ha_replicas": 1, "memory_gb": 2, "milli_cpu": 1000, "sync_replicas": 0 } } ], "spec": { "hostname": "my-service.timescale.com", "pooler_hostname": "my-service-pooler.timescale.com", "pooler_port": 6432, "port": 5432, "replica_hostname": "my-service-replica.timescale.com", "replica_port": 5432, "username": "tsuser" } } ``` -------------------------------- ### Timescale Metric Exporter Resource Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/metric_exporter.md This resource allows you to configure and deploy metric exporters for services within Timescale. It supports exporting metrics to Datadog, Prometheus, and AWS CloudWatch. ```APIDOC ## RESOURCE timescale_metric_exporter ### Description Schema for a metric exporter. This resource allows you to configure and deploy metric exporters for services within Timescale. It supports exporting metrics to Datadog, Prometheus, and AWS CloudWatch. ### Schema #### Required - `name` (String) - Metric exporter name. - `region` (String) - Region where the exporter will be deployed. Only services running in the same region can be attached. #### Optional - `cloudwatch` (Attributes) - Configuration for AWS CloudWatch exporter. Configure authentication using either `role_arn` or `access_key` with `secret_key`. Cannot be used with `datadog` or `prometheus`. #### Nested Schema for `cloudwatch` Required: - `log_group_name` (String) - Name of the CloudWatch Log Group. - `log_stream_name` (String) - Name of the CloudWatch Log Stream. - `namespace` (String) - CloudWatch Metric Namespace. - `region` (String) - AWS region for CloudWatch. Optional: - `access_key` (String) - AWS access key ID. If provided, `secret_key` must also be set, and `role_arn` must not be set. - `role_arn` (String) - ARN of the IAM role to assume for CloudWatch access. If provided, `access_key` and `secret_key` must not be set. - `secret_key` (String, Sensitive) - AWS secret access key. If provided, `access_key` must also be set, and `role_arn` must not be set. - `datadog` (Attributes) - Configuration for Datadog exporter. Cannot be used with `prometheus` or `cloudwatch`. #### Nested Schema for `datadog` Required: - `api_key` (String, Sensitive) - Datadog API key. - `site` (String) - Datadog site (e.g., 'datadoghq.com', 'datadoghq.eu'). - `prometheus` (Attributes) - Configuration for Prometheus exporter. Cannot be used with `datadog` or `cloudwatch`. #### Nested Schema for `prometheus` Required: - `password` (String, Sensitive) - Password for Prometheus basic authentication. - `username` (String) - Username for Prometheus basic authentication. ### Read-Only - `created` (String) - Timestamp of when the metric exporter was created (RFC3339 format). - `id` (String) - Metric exporter ID. - `type` (String) - Type of the metric exporter. Possible values: datadog, prometheus, cloudwatch. ``` -------------------------------- ### Configure Timescale Provider Authentication (HCL) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/index.md This HCL code block configures the Timescale Terraform provider, specifying the project ID, access key, and secret key for authentication. These credentials are typically obtained from the Timescale UI. ```hcl provider "timescale" { project_id = var.ts_project_id access_key = var.ts_access_key secret_key = var.ts_secret_key } ``` -------------------------------- ### Define Timescale Service Variables (HCL) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md This HCL snippet defines variables for Timescale project ID, access key, and secret key, which are required for authentication with the Timescale provider. ```hcl variable "ts_project_id" { type = string } variable "ts_access_key" { type = string } variable "ts_secret_key" { type = string sensitive = true } ``` -------------------------------- ### VPC Peering Connection (Timescale to AWS) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/peering_connection.md Establishes a VPC peering connection between a Timescale VPC and an AWS VPC. It requires the peer account ID, region, the peer VPC ID, and optionally peer CIDR blocks. The Timescale VPC ID is also a mandatory parameter. ```terraform # Creating a test VPC in eu-central-1 resource "aws_vpc" "main" { cidr_block = "11.0.0.0/24" tags = { Name = "tf-test-vpc-peering" } } # Requester's side of the VPC peering connection (Timescale). resource "timescale_peering_connection" "vpc_peer" { peer_account_id = "000000000000" peer_region_code = "eu-central-1" peer_vpc_id = aws_vpc.main.id peer_cidr_blocks = ["12.0.0.0/24", "12.1.0.0/24"] # Optional for VPC peering timescale_vpc_id = timescale_vpcs.ts-test.id } # Acceptor's side of the VPC peering connection (AWS). resource "aws_vpc_peering_connection_accepter" "vpc_peer" { vpc_peering_connection_id = timescale_peering_connection.vpc_peer.accepter_provisioned_id auto_accept = true } ``` -------------------------------- ### Timescale VPC Peering Connection Resource Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md Defines the Timescale side of a VPC peering connection, specifying the peer account ID, region, and VPC IDs for both the peer and Timescale networks. It requires the Timescale provider. ```terraform resource "timescale_peering_connection" "peer" { peer_account_id = "000000000000" peer_region_code = "eu-central-1" peer_vpc_id = aws_vpc.main.id timescale_vpc_id = timescale_vpcs.ts-test.id } ``` -------------------------------- ### AWS VPC Peering Connection Requester Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md Configures the AWS side to accept a VPC peering connection initiated by Timescale. It references the provisioned ID from the Timescale peering connection and automatically accepts the request. It depends on the Timescale peering connection resource. ```terraform resource "aws_vpc_peering_connection_accepter" "peer" { vpc_peering_connection_id = timescale_peering_connection.peer.accepter_provisioned_id auto_accept = true depends_on = [timescale_peering_connection.peer] } ``` -------------------------------- ### Configure Timescale VPC Peering (HCL) Source: https://github.com/timescale/terraform-provider-timescale/blob/main/templates/index.md This HCL configuration sets up a Timescale VPC and an AWS VPC, and establishes a peering connection between them. It requires specifying regions, CIDRs, and potentially updating AWS provider configurations. ```hcl terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } # Authenticate using client credentials. # They are issued through the Timescale UI. # When required, they will exchange for 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 sensitive = true } resource "timescale_vpcs" "ts-test" { cidr = "10.0.0.0/24" name = "tf-test" region_code = "us-east-1" } # If you have multiple regions, you’ll need to use multiple `provider` configurations. provider "aws" { region = "eu-central-1" } # Creating a test VPC. Change to your VPC if you already have one in your AWS account. resource "aws_vpc" "main" { cidr_block = "11.0.0.0/24" } ``` -------------------------------- ### Configure Timescale Log Exporter for CloudWatch with Static Keys Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/log_exporter.md This Terraform configuration defines a timescale log exporter to send logs to AWS CloudWatch using static AWS access and secret keys for authentication. It specifies the log group name, log stream name, and the AWS region. A Timescale service is also created and linked to this log exporter. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } 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 sensitive = true } resource "timescale_log_exporter" "my_cloudwatch_exporter_with_keys" { name = "CloudWatch Log Exporter via Static Keys" region = "us-east-1" cloudwatch = { region = "us-east-1" access_key = "your_access_key_" secret_key = "your_secret_keyxxxxxxxxxxxxxxxxxxxxxxxxx" log_group_name = "/anotherapplication/logs" log_stream_name = "exporter-stream-keys" } } resource "timescale_service" "log_exporter_test" { name = "log_exporter_test" milli_cpu = 1000 memory_gb = 4 region_code = "us-east-1" log_exporter_id = timescale_log_exporter.my_cloudwatch_exporter_with_keys.id } ``` -------------------------------- ### Configure Timescale Log Exporter for CloudWatch with IAM Role Source: https://github.com/timescale/terraform-provider-timescale/blob/main/docs/resources/log_exporter.md This Terraform configuration defines a timescale log exporter to send logs to AWS CloudWatch using an IAM role for authentication. It specifies the log group name, log stream name, and the ARN of the IAM role to be assumed. A Timescale service is also created and linked to this log exporter. ```terraform terraform { required_providers { timescale = { source = "timescale/timescale" version = "~> 2.5" } } } 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 sensitive = true } resource "timescale_log_exporter" "my_cloudwatch_exporter_with_role" { name = "CloudWatch Log Exporter via IAM Role from TF" region = "us-east-1" cloudwatch = { region = "us-east-1" role_arn = "arn:aws:iam::123456789012:role/MyLogsExporterRole" log_group_name = "/myapplication/logs" log_stream_name = "exporter-stream-role" } } resource "timescale_service" "log_exporter_test" { name = "log_exporter_test" milli_cpu = 1000 memory_gb = 4 region_code = "us-east-1" log_exporter_id = timescale_log_exporter.my_cloudwatch_exporter_with_keys.id } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.