hashicorp / terraform-github-actions

Terraform GitHub Actions
Mozilla Public License 2.0
627 stars 321 forks source link

Terraform init does not respect its working directory #110

Closed JamesWoolfenden closed 4 years ago

JamesWoolfenden commented 5 years ago

I'm trying to set up a basic work flow for a module and so i'm using terraform init and validate. (Following the example for working dir in your subdir).

  examples:
    name: 'Terraform (examples)'
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout'
        uses: actions/checkout@master
      - name: 'Terraform Init'
        uses: hashicorp/terraform-github-actions@master
        with:
          tf_actions_version: 0.12.13
          tf_actions_subcommand: 'init'
          tf_actions_working_dir: 'example'
      - name: 'Terraform Validate'
        uses: hashicorp/terraform-github-actions@master
        with:
          tf_actions_version: 0.12.13
          tf_actions_subcommand: 'validate'
          tf_actions_working_dir: 'example'

I need to target the template example folder in the root, where i have a provider and module. The init does nto repsect the working dir

Terraform Init

Run hashicorp/terraform-github-actions@master
/usr/bin/docker run --name d400a31e4708945999e92e36d2aa30fd5_894a8e --label 10865d --workdir /github/workspace --rm -e INPUT_TF_ACTIONS_VERSION -e INPUT_TF_ACTIONS_SUBCOMMAND -e INPUT_TF_ACTIONS_WORKING_DIR -e INPUT_TF_ACTIONS_COMMENT -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/terraform-aws-githubactions/terraform-aws-githubactions":"/github/workspace" 10865d:400a31e4708945999e92e36d2aa30fd5
Downloading Terraform v0.12.13
Successfully downloaded Terraform v0.12.13
Unzipping Terraform v0.12.13
Successfully unzipped Terraform v0.12.13
init: info: initializing Terraform configuration in example
init: info: successfully initialized Terraform configuration in example
Terraform initialized in an empty directory!

The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.

So the directory isn't empty, i know this because the validate step fails because it does find the module and provider

Terraform Validate
##[error]Docker run failed with exit code 1
Run hashicorp/terraform-github-actions@master
/usr/bin/docker run --name d400a31e4708945999e92e36d2aa30fd5_2aec25 --label 10865d --workdir /github/workspace --rm -e INPUT_TF_ACTIONS_VERSION -e INPUT_TF_ACTIONS_SUBCOMMAND -e INPUT_TF_ACTIONS_WORKING_DIR -e INPUT_TF_ACTIONS_COMMENT -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/terraform-aws-githubactions/terraform-aws-githubactions":"/github/workspace" 10865d:400a31e4708945999e92e36d2aa30fd5
Downloading Terraform v0.12.13
Successfully downloaded Terraform v0.12.13
Unzipping Terraform v0.12.13
Successfully unzipped Terraform v0.12.13
validate: info: validating Terraform configuration in example
validate: error: failed to validate Terraform configuration in example

Error: Module not installed

  on module.action.tf line 1:
   1: module action {

This module is not yet installed. Run "terraform init" to install all modules
required by this configuration.

Any ideas what happening?

sudomateo commented 5 years ago

Should be fixed in #111 which is released as v0.6.1.

JamesWoolfenden commented 4 years ago

Confirmed it now does as it says on the tin. Thanks