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

# Authentication

> Authenticate the Strettch Cloud Terraform provider with an API key, locally and in CI.

The provider authenticates with a Strettch Cloud **API key**, sent as a bearer token on every request.

## Create an API key

Generate an API key in the [Strettch Cloud console](https://cloud.strettch.com/p/settings/api-keys). Keep it somewhere safe — it acts with the same [permissions](https://cloud.strettch.com/docs/services/teams/overview.md#team-roles-and-permissions) as the member who created it.

## Provide the key

The recommended way is the `STRETTCH_CLOUD_API_KEY` environment variable, so the key never lands in your configuration files:

```bash theme={null}
export STRETTCH_CLOUD_API_KEY="<your api key>"
```

```hcl main.tf theme={null}
provider "strettchcloud" {
  # api_key is read from STRETTCH_CLOUD_API_KEY
}
```

> [!TIP]
>
> Typing the key as an argument records it in your shell history. To avoid that, read it interactively instead:
>
> ```bash theme={null}
> read -rs STRETTCH_CLOUD_API_KEY && export STRETTCH_CLOUD_API_KEY
> ```

You *can* set it inline with the `api_key` argument, but only if the value comes from a variable or secret store — never a literal in version control:

```hcl theme={null}
variable "strettchcloud_api_key" {
  type      = string
  sensitive = true
}

provider "strettchcloud" {
  api_key = var.strettchcloud_api_key
}
```

> [!WARNING]
>
> A saved plan (`terraform plan -out=...`) stores input variable values in **cleartext**, even when marked `sensitive`. Anyone who can read the plan file can recover the key — so prefer the environment variable for automation, and protect any plan artifacts you keep.

> [!WARNING]
>
> Never commit your API key. Treat it like a password: use an environment variable or a secrets manager, and rotate it if it is ever exposed.

## In CI/CD

Store the key as a secret in your CI system and expose it as `STRETTCH_CLOUD_API_KEY` for the plan/apply steps. For example, in GitHub Actions:

```yaml theme={null}
env:
  STRETTCH_CLOUD_API_KEY: ${{ secrets.STRETTCH_CLOUD_API_KEY }}
```

## On HCP Terraform

Set `STRETTCH_CLOUD_API_KEY` as a **sensitive** workspace environment variable. It is then write-only — it cannot be read back through the UI or API, and it is kept out of your configuration and state.

> [!NOTE]
>
> Log redaction is best-effort, not a guarantee. Verbose logging such as `TF_LOG=TRACE` can print environment variables, so avoid it in shared or recorded runs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.