Retrieve Terraform root-level outputs with terraform-output
mainThe terraform-output action retrieves root-level outputs from a Terraform configuration and makes them available as GitHub Actions outputs or a JSON file. This is useful for passing infrastructure metadata (like hostnames, IDs, or network configurations) from a Terraform apply step to subsequent steps in a workflow.
Key Features
- Individual Outputs: Every Terraform output becomes a unique GitHub Action output.
- JSON File: A single JSON file containing all outputs is generated at the path specified by
json_output_path. - Type Casting:
- Primitives (string, number, bool): Cast to strings (booleans become
'true'or'false'). - Complex Types (list, set, tuple, map, object): Cast to a JSON string. Use the GitHub Actions
fromJson()function to parse them back into objects/arrays.
- Primitives (string, number, bool): Cast to strings (booleans become
- name: Get outputs
uses: dflook/terraform-output@v2
id: tf-outputs
with:
path: my-terraform-config