Skip to content

tfsubst action

Actions
Substitute variables with tfstate values
v0.0.5
Latest
Star (0)

tfsubst

tfstate substitution tool like envsubst.

Usage

tfsubst substitutes all variables in the file with the values from the tfstate.

$ tfsubst -s <tfstate-file> -i <input-file>

Example

If you have a template file below

# input.yaml
value: {{ tfstate "aws_ssm_parameter.your_parameter.value" }}

and your tfstate is in s3://yourbucket/terraform.tfstate

then the output file will be

$ tfsubst -s s3://yourbucket/terraform.tfstate -i input.yaml -o output.yaml
# output.yaml
value: your_parameter_value

Installation

From binary

Download the binary from GitHub Releases and drop it in your $PATH.
Or one-liner installation command is below.(jq is required)

$ curl -sfL https://raw.githubusercontent.com/RossyWhite/tfsubst/main/install.sh | sh

With Go

$ go install github.com/rossywhite/tfsubst@latest

Docker

$ docker pull ghcr.io/rossywhite/tfsubst:latest

Use in GitHub Actions

- name: run tfsubst
  uses: RossyWhite/tfsubst@v0.0.4
  with:
    input: <your input file path>
    output: <your output file path>
    tfstate: <your tfstate file path>

tfsubst action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Substitute variables with tfstate values
v0.0.5
Latest

tfsubst action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.