Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
code

GitHub Action

Terraform Cloud Remote Action

v1.0.0

Terraform Cloud Remote Action

code

Terraform Cloud Remote Action

Fetch output variable values from Terraform Cloud

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Terraform Cloud Remote Action

uses: paambaati/[email protected]

Learn more about this action in paambaati/tfc-output-action

Choose a version

tfc-output-action

Test Coverage Build Status MIT License

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. Read 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 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.