> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamkap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Configure the Streamkap Terraform Provider with credentials and create your first resources.

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](/terraform-installation) (version 1.0 or later)
* A Streamkap account with access to a Project
* API credentials (Client ID and Secret) from Streamkap

## Step 1: Create API Credentials

<Steps>
  <Step title="Navigate to API Tokens">
    Log in to your Streamkap account and navigate to your project's **Project Settings**.
  </Step>

  <Step title="Open API Tokens">
    Click on the **API** tab to access API Tokens.
  </Step>

  <Step title="Create a new token">
    Click **Create API Token**, enter a description (e.g., "Terraform automation"), select the appropriate role(s), and click **Create Token**.
  </Step>

  <Step title="Save credentials securely">
    Copy the **Client ID** and **Token** immediately. The token is only shown once.
  </Step>
</Steps>

<Warning>
  Store your credentials securely. Never commit them to version control.
</Warning>

## Step 2: Configure Credentials

Set your credentials as environment variables. This is the recommended approach for security.

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    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.
  </Tab>

  <Tab title="Windows (PowerShell)">
    ```powershell theme={null}
    $env:STREAMKAP_CLIENT_ID = "your-client-id"
    $env:STREAMKAP_SECRET = "your-token-secret"
    ```

    For persistent environment variables, set them via System Properties or your PowerShell profile.
  </Tab>

  <Tab title="Windows (CMD)">
    ```batch theme={null}
    set STREAMKAP_CLIENT_ID=your-client-id
    set STREAMKAP_SECRET=your-token-secret
    ```
  </Tab>
</Tabs>

## Step 3: Create Your Terraform Configuration

Create a new directory for your Terraform project and add the following `main.tf` file.

<Tabs>
  <Tab title="Beta">
    The beta version exposes significantly more resources — all source and destination connectors, transform resources, and more.

    ```hcl theme={null}
    terraform {
      required_providers {
        streamkap = {
          source  = "streamkap-com/streamkap"
          version = "3.0.0-beta.6"
        }
      }
    }

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

    <Note>
      Pre-release versions require an exact version constraint — Terraform does not auto-select pre-release versions with `>=` or `~>` operators.
    </Note>
  </Tab>

  <Tab title="Stable">
    The stable version supports a subset of connectors. See the [Resource Reference](/terraform-resources) for details.

    ```hcl theme={null}
    terraform {
      required_providers {
        streamkap = {
          source  = "streamkap-com/streamkap"
          version = "~> 2.1.19"
        }
      }
    }

    provider "streamkap" {
      # Credentials are loaded from environment variables:
      # STREAMKAP_CLIENT_ID and STREAMKAP_SECRET
    }
    ```
  </Tab>
</Tabs>

<Info>
  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.
</Info>

## Step 4: Initialize and Apply

Run the following commands in your project directory:

```bash theme={null}
# 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:

| Parameter   | Environment Variable  | Default                     | Description                     |
| ----------- | --------------------- | --------------------------- | ------------------------------- |
| `client_id` | `STREAMKAP_CLIENT_ID` | -                           | Your Streamkap API client ID    |
| `secret`    | `STREAMKAP_SECRET`    | -                           | Your Streamkap API token/secret |
| `host`      | `STREAMKAP_HOST`      | `https://api.streamkap.com` | API endpoint URL                |

## 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 can 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

* Browse the [Resource Reference](/terraform-resources) for all available Streamkap resources
* Browse the [Streamkap Terraform Provider](https://registry.terraform.io/providers/streamkap-com/streamkap/latest/docs) on the HashiCorp Registry for full attribute documentation
* Learn about [Terraform state management](https://developer.hashicorp.com/terraform/language/state) for team workflows
* See [API Tokens](/api-tokens) for more details on managing Streamkap credentials
