workload_identity block in place of api_key. The provider gets a JWT from the platform that runs Terraform, exchanges it, and uses the Dodo token for the run.
The
workload_identity block is available from provider version 0.3.0.Provider Configuration
workload_identity is a block, not an attribute. Do not write workload_identity = { ... }.
Token Sources
HCP Terraform
1
Create the provider and the mappings
In the dashboard, create a
terraform_cloud provider. Then add mappings that pin terraform_organization_id and terraform_workspace_id. Refer to Terraform Cloud.2
Set the workspace variables
In the HCP Terraform workspace, add these environment variables:
3
Configure the provider
Set
token_source = "terraform_cloud" in the workload_identity block. Remove DODO_PAYMENTS_API_KEY from the workspace.Split Plan and Apply
HCP Terraform adds theterraform_run_phase claim (plan or apply) to the JWT. Use it to give the plan phase read access only:
Each JWT matches one mapping only, because the two mappings have different
terraform_run_phase values.
A terraform_cloud Dodo token lives until the end of the run phase, with a maximum of 24 hours. Pin terraform_run_phase to keep write access in the apply phase only.
GitHub Actions
Give the job theid-token: write permission. The provider requests the JWT. If you do not add a workload_identity block and DODO_PAYMENTS_API_KEY is not set, the auto token source finds GitHub Actions.
Environment Variables
Terraform Provider
Manage your catalog as code.
Terraform Cloud Guide
Provider and mapping setup for HCP Terraform.