How to use terraform setup github action with config files in non-root directory

Hi all,

I want to use the terraform github action to trigger a plan and apply to TF Cloud (using the API token).

My config files are not stored in the root directory so I receive the following message at the plan step:

Error: No configuration files

Plan requires configuration to be present. Planning without a configuration
would mark everything for destruction, which is normally not what is desired.
If you would like to destroy everything, run plan with the -destroy option.
Otherwise, create a Terraform configuration file (.tf file) and try again.

##[error]Terraform exited with code 1.
##[error]Process completed with exit code 1.

How can I specify the config files directory?

I use the following workflow commands:

terraform:

    name: 'Terraform'
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup Terraform
      uses: hashicorp/setup-terraform@v1
      with:
        cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

    - name: Terraform Init
      run: terraform init

    - name: Terraform Format
      run: terraform fmt -check

    - name: Terraform Plan
      run: terraform plan

    - name: Terraform Apply
      run: terraform apply -auto-approve

Try adding a working-directory directory value to the job definition.

jobs:
  terraform:
    defaults:
      run:
        working-directory: $DIR_OF_CHOICE
# ... rest elided