mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-17 08:52:37 +00:00
Merge 2bacb8dba8 into 92e4d08fe1
This commit is contained in:
commit
a23c7273ae
1 changed files with 31 additions and 0 deletions
31
README.md
31
README.md
|
|
@ -264,6 +264,37 @@ to `true`, the following outputs are available for subsequent steps that call th
|
|||
- `stderr` - The STDERR stream of the call to the `terraform` binary.
|
||||
- `exitcode` - The exit code of the call to the `terraform` binary.
|
||||
|
||||
## Examples
|
||||
|
||||
### Passing variables to Terraform
|
||||
|
||||
Since Terraform cloud does not support run variables at this time.
|
||||
Currently the only to way to pass variables is by creating a `*.auto.tfvars` variables file.
|
||||
|
||||
In this example, we will create a `pipeline.auto.tfvars` file and append all of the variables which we need to pass on to Terraform.
|
||||
|
||||
Add the following step in your workflow file
|
||||
|
||||
```yaml
|
||||
- name: Setup Terraform variables
|
||||
working-directory: ./terraform
|
||||
id: vars
|
||||
run: |-
|
||||
cat > pipeline.auto.tfvars <<EOF
|
||||
image_tag = "${{ github.sha }}"
|
||||
EOF
|
||||
```
|
||||
|
||||
And also define these variables in one of your Terraform configuration files. For example, we will add the following in `variables.tf`
|
||||
|
||||
```
|
||||
variable "image_tag" {
|
||||
}
|
||||
```
|
||||
|
||||
`image_tag` will be available in terraform which you can access via `var.image_tag`
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[Mozilla Public License v2.0](LICENSE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue