GitHub Action
Terraform Cloud Remote Action
A GitHub action that fetches Terraform Output values from Terraform Cloud remote state. Additionally, it securely handles sensitive output.
This is useful when you've provisioned your infrastructure using Terraform and would like to access some values –
- In one stack from another stack.
- 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.
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
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. |
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/tfc-output-action@v1.0.8
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 }}"
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.