Skip to main content
This guide walks you through configuring the Streamkap Terraform Provider and creating your first infrastructure-as-code configuration.

Prerequisites

Before you begin, ensure you have:
  • Terraform installed (version 1.0 or later)
  • A Streamkap account with access to a Service
  • API credentials (Client ID and Secret) from Streamkap

Step 1: Create API Credentials

1

Navigate to API Tokens

Log in to your Streamkap account and go to the Services page.
2

Open API Tokens

For your Service, click the menu (three dots) and select API Tokens.
3

Create a new token

Click Create API Token, enter a description (e.g., “Terraform automation”), select the appropriate role(s), and click Create Token.
4

Save credentials securely

Copy the Client ID and Token immediately. The token is only shown once.
Store your credentials securely. Never commit them to version control.

Step 2: Configure Credentials

Set your credentials as environment variables. This is the recommended approach for security.
export STREAMKAP_CLIENT_ID="your-client-id"
export STREAMKAP_SECRET="your-token-secret"
To persist these across terminal sessions, add them to your ~/.bashrc, ~/.zshrc, or equivalent shell configuration file.

Step 3: Create Your Terraform Configuration

Create a new directory for your Terraform project and add the following main.tf file:
terraform {
  required_providers {
    streamkap = {
      source  = "streamkap-com/streamkap"
      version = ">= 2.1.18"
    }
  }
}

provider "streamkap" {
  # Credentials are loaded from environment variables:
  # STREAMKAP_CLIENT_ID and STREAMKAP_SECRET

  # Optionally specify a custom API host (e.g., for development environments):
  # host = "https://api-dev.streamkap.com"
}
The provider automatically reads credentials from the STREAMKAP_CLIENT_ID and STREAMKAP_SECRET environment variables. You can also set them directly in the provider block, but this is not recommended for security reasons.

Step 4: Initialize and Apply

Run the following commands in your project directory:
# Initialize Terraform (downloads the provider)
terraform init

# Preview what will be created
terraform plan

# Apply the configuration (when you have resources defined)
terraform apply

Provider Configuration Reference

The Streamkap provider supports the following configuration options:
ParameterEnvironment VariableDefaultDescription
client_idSTREAMKAP_CLIENT_ID-Your Streamkap API client ID
secretSTREAMKAP_SECRET-Your Streamkap API token/secret
hostSTREAMKAP_HOSThttps://api.streamkap.comAPI endpoint URL

Example: Creating a PostgreSQL Source

Here’s an example of defining a PostgreSQL source connector:
resource "streamkap_source_postgresql" "my_postgres" {
  name              = "production-postgres"
  database_hostname = "db.example.com"
  database_port     = 5432
  database_dbname   = "mydb"
  database_user     = var.db_username
  database_password = var.db_password
  database_sslmode  = "require"

  schema_include_list = "public"
  table_include_list  = "public.orders,public.customers"

  snapshot_read_only  = "No"
  signal_data_collection_schema_or_database    = "streamkap"
  heartbeat_enabled                            = true
  heartbeat_data_collection_schema_or_database = "streamkap"

  slot_name        = "streamkap_slot"
  publication_name = "streamkap_pub"
}
Use Terraform variables for sensitive values like passwords. See Terraform Input Variables for more information.

Project Structure Recommendation

For larger projects, organize your Terraform files like this:
streamkap-terraform/
├── main.tf           # Provider configuration
├── variables.tf      # Variable definitions
├── sources.tf        # Source connector resources
├── destinations.tf   # Destination connector resources
├── pipelines.tf      # Pipeline resources
├── outputs.tf        # Output values
├── terraform.tfvars  # Variable values (add to .gitignore!)
└── .gitignore        # Exclude sensitive files
Here is an example .gitignore file you case use to exclude sensitive files:
# Terraform state files (contain sensitive data)
*.tfstate
*.tfstate.*

# Terraform variable files with secrets
terraform.tfvars
*.auto.tfvars

# Terraform cache
.terraform/

# Crash logs
crash.log
crash.*.log

Next Steps