Terraform Credentials from the macOS Keychain

terraform-credentials-keychain is a shell script which implements the Terraform credentials helpers API, allowing you to store and retrieve credentials for services like Terraform Cloud securely in the macOS Keychain.

Note: Consider using bendrucker/terraform-credentials-helper, which is more likely to be maintained.

Usage

  1. Download the terraform-credentials-keychain file from this repository, and copy it to your global plugins path, ~/.terraform.d/plugins.

  2. Edit your Terraform CLI configuration to enable the helper:

    credentials_helper "keychain" {}
  3. Ensure that you have manually configured an empty block for the public registry in the same file:

    credentials "registry.terraform.io" {}

    This ensures that the helper is not triggered for API calls which install providers and modules.

  4. Use terraform login to create a Terraform Cloud token and store it in your keychain.

  5. Later you can remove the stored token with terraform logout