1
Create a Machine Identity in Infisical
Follow the instructions in this documentation to create a machine identity with OIDC auth. Infisical OIDC configuration values for Terraform Cloud:
- Set the OIDC Discovery URL to https://app.terraform.io.
- Set the Issuer to https://app.terraform.io.
- Configure the Audience to match the value you will use for TFC_WORKLOAD_IDENTITY_AUDIENCE in Terraform Cloud for the next step.
2
Enable Workload Identity Token Injection in Terraform Cloud
- Navigate to your workspace in Terraform Cloud.
- Add a workspace variable named
TFC_WORKLOAD_IDENTITY_AUDIENCE
:
- Key:
TFC_WORKLOAD_IDENTITY_AUDIENCE
- Value: For example,
my-infisical-audience
- Category: Environment
Important:Once set, Terraform Cloud will inject a workload identity token into the run environment as
- The presence of
TFC_WORKLOAD_IDENTITY_AUDIENCE
is required for Terraform Cloud to inject a token.- If you are self-hosting HCP Terraform agents, ensure they are v1.7.0 or above.
TFC_WORKLOAD_IDENTITY_TOKEN
.If you are running on self-hosted HCP Terraform agents, you must use v1.7.0 or later to enable token injection. If you need to generate multiple tokens, you must use v1.12.0 or later.
3
Configure the Infisical Provider
In your Terraform configuration, reference the injected token by name. For example:
host
: Defaults tohttps://app.infisical.com
. Override if using a self-hosted Infisical instance.identity_id
: The OIDC identity ID from Infisical.token_environment_variable_name
: Must match the injected variable name from Terraform Cloud. If using single token, useTFC_WORKLOAD_IDENTITY_TOKEN
. If using multiple tokens, choose the one you want to use (e.g.,TFC_WORKLOAD_IDENTITY_TOKEN_INFISICAL
).
4
Validate Your Setup
- Run a plan and apply in Terraform Cloud.
- Verify the Infisical provider authenticates successfully without issues. If you run into authentication errors, double-check the Infisical identity has the correct roles/permissions in Infisical.