This is one of a suite of terraform related actions - find them at dflook/terraform-github-actions.
This action determines the terraform and provider versions to use for a terraform configuration directory.
The version to use is discovered from the first of:
- A
required_version
constraint in the terraform configuration. - A tfswitch
.tfswitchrc
file - A tfenv
.terraform-version
file in path of the terraform configuration. - The latest terraform version
The version of terraform and all required providers will be output to the workflow log.
Other terraform actions automatically determine the terraform version in the same way. You only need to run this action if you want to use the outputs yourself.
-
path
Path to the terraform configuration to apply
- Type: string
- Required
-
terraform
The terraform version that is used by the terraform configuration
-
Provider Versions
Additional outputs are added with the version of each provider that is used by the terraform configuration. For example, if the random provider is used:
provider "random" { version = "2.2.0" }
A
random
output will be created with the value2.2.0
.
on: [push]
jobs:
required_version:
runs-on: ubuntu-latest
name: Print the required terraform and provider versions
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Test terraform-version
uses: dflook/terraform-version@v1
id: terraform-version
with:
path: my-configuration
- name: Print the version
run: echo "The terraform version was ${{ steps.terraform-version.outputs.terraform }}"
- name: Print aws provider version
run: echo "The terraform version was ${{ steps.terraform-version.outputs.aws }}"