tfc-output-action

GitHub Action to fetch output variable values from Terraform Cloud

MIT License

Stars
2
Committers
2

tfc-output-action

A GitHub action that fetches Terraform Output values from Terraform Cloud remote state. Additionally, it securely handles sensitive output.

Why?

This is useful when you've provisioned your infrastructure using Terraform and would like to access some values –

  1. In one stack from another stack.
  2. In other workflows or projects (backend deployments, codegen scripts, etc.) that need access to values from Terraform.

With this workflow, you do not need to hardcode values from Terraform ever.

Usage

This action requires that you have a Terraform Cloud account and an API token. Learn how to get one in the official documentation – https://www.terraform.io/cloud-docs/users-teams-organizations/api-tokens

Inputs

Input Description
apiToken API token from Terraform Cloud.
workspaceId Terraform Cloud workspace ID.
variableName Name of the Terraform Cloud output variable you want to retrieve.

Example

Assuming you have a Terraform Output variable called iam-user-name, here's how you'd access it in a workflow.

steps:
  - name: Fetch remote value from Terraform
    uses: paambaati/[email protected]
    id: tfc-output
    with:
      apiToken: ${{ secrets.TF_API_TOKEN }}
      workspaceId: ws-PK3vmEp8KNcqekcu
      variableName: 'iam-user-name'

  - name: Print the value
    run: echo "IAM user name is ${{ steps.tfc-output.outputs.value }}"

Sensitive Output

If your Terraform Output is marked as sensitive, the output value from this action is also masked, and so it is not exposed in workflow logs.

Package Rankings
Top 26.26% on Github actions
Badges
Extracted from project README
Test Coverage Build Status MIT License