Closed DawidNiezgodka closed 1 year ago
Hello, thanks for creating an issue.
'terraform/input.tfvars' should be correct. Can you post the full workflow and workflow log from GitHub?
Thanks for the quick response.
Here's the caller workflow:
name: 'Caller workflow'
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
workflow_caller_test:
permissions:
contents: read
id-token: write
uses: ./.github/workflows/core.yml
with:
working_directory: ${{ github.workspace }}
secrets: inherit
Here's the called workflow:
on:
workflow_call:
inputs:
working_directory:
type: string
description: |
The working directory to run the benchmark in.
Needs to be relative to the root of the repository.
required: false
jobs:
continuous_benchmarking:
permissions:
contents: read
id-token: write
name: Continuous Benchmarking
runs-on: ubuntu-latest
defaults:
run:
shell: bash
##############################################################
################ Basic steps + Auth ################
##############################################################
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.SERV_ACC_KEY }}
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@v1
with:
version: '>= 363.0.0'
- name: Get runner IP
run: |
ip=`curl https://ipinfo.io/ip`
echo $ip
echo "runner_ip=$ip" >> $GITHUB_ENV
##############################################################
################ Terraform ################
##############################################################
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# Set to false, otherwise it's impossible to use terraform output in consecutive steps
terraform_wrapper: false
- name: Terraform apply
uses: dflook/terraform-apply@v1
with:
path: terraform
auto_approve: true
var_file: |
terraform/input.tfvars
variables: |
runner_ip=${{ env.runner_ip }}
gha_workspace=${{ github.workspace }}
Workflow log - a bit shortened and redacted. Lemme know if you need some more info.
##[debug]Evaluating condition for step: 'Terraform apply'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Terraform apply
##[debug]Loading inputs
##[debug]Evaluating: format('runner_ip=***0***
##[debug]gha_workspace=***1***
##[debug]', env.runner_ip, github.workspace)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> 'runner_ip=***0***
##[debug]gha_workspace=***1***
##[debug]'
##[debug]..Evaluating Index:
##[debug]....Evaluating env:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'runner_ip'
##[debug]..=> '1.2.3.4'
##[debug]..Evaluating Index:
##[debug]....Evaluating github:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'workspace'
##[debug]..=> '/home/runner/work/Repo1/Repo1'
##[debug]=> 'runner_ip=1.2.3.4
##[debug]gha_workspace=/home/runner/work/Repo1/Repo1
##[debug]'
##[debug]Result: 'runner_ip=1.2.3.4
##[debug]gha_workspace=/home/runner/work/Repo1/Repo1
##[debug]'
##[debug]Loading env
Run dflook/terraform-apply@v1
with:
path: terraform
auto_approve: true
var_file: terraform/input.tfvars
variables: runner_ip=1.2.3.4
gha_workspace=/home/runner/work/Repo1/Repo1
workspace: default
parallelism: 0
destroy: false
env:
CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/Repo1/Repo1/gha-creds
GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/Repo1/Repo1/gha-creds
GOOGLE_GHA_CREDS_PATH: /home/runner/work/Repo1/Repo1/gha-creds
CLOUDSDK_CORE_PROJECT: project1
CLOUDSDK_PROJECT: project1
GCLOUD_PROJECT: project1
GCP_PROJECT: project1
GOOGLE_CLOUD_PROJECT: project1
CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
CLOUDSDK_METRICS_ENVIRONMENT_VERSION: 1.1.1
runner_ip: 1.2.3.4
/usr/bin/docker run --name danielflookterraformgithubactionssha256c2bf_40f80a
--label c9a4a5 --workdir /github/workspace --rm -e "CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE" -e "GOOGLE_APPLICATION_CREDENTIALS" -e "GOOGLE_GHA_CREDS_PATH"
-e "CLOUDSDK_CORE_PROJECT" -e "CLOUDSDK_PROJECT" -e "GCLOUD_PROJECT" -e "GCP_PROJECT"
-e "GOOGLE_CLOUD_PROJECT" -e "CLOUDSDK_METRICS_ENVIRONMENT" -e "CLOUDSDK_METRICS_ENVIRONMENT_VERSION" -e "runner_ip" -e "INPUT_PATH"
-e "INPUT_AUTO_APPROVE" -e "INPUT_VAR_FILE" -e "INPUT_VARIABLES" -e "INPUT_WORKSPACE" -e "INPUT_BACKEND_CONFIG" -e "INPUT_BACKEND_CONFIG_FILE"
-e "INPUT_VAR" -e "INPUT_PARALLELISM" -e "INPUT_LABEL" -e "INPUT_TARGET" -e "INPUT_REPLACE" -e "INPUT_DESTROY" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF"
-e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS"
-e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF"
-e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF"
-e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY"
-e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_DEBUG" -e "RUNNER_OS" -e "RUNNER_ARCH"
-e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL"
-e "ACTIONS_ID_TOKEN_REQUEST_URL" -e "ACTIONS_ID_TOKEN_REQUEST_TOKEN" -e GITHUB_ACTIONS=true -e CI=true --entrypoint "/entrypoints/apply.sh"
-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/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/Repo1/Repo1":"/github/workspace"
danielflook/terraform-github-actions@sha256:c2bf
##[debug]pwd:/github/workspace
##[debug]ls -la:total 44
##[debug]ls -la:drwxr-xr-x 8 1001 123 4096 Jul 23 13:08 .
##[debug]ls -la:drwxr-xr-x 6 root root 4096 Jul 23 13:09 ..
##[debug]ls -la:drwxr-xr-x 8 1001 123 4096 Jul 23 13:08 .git
##[debug]ls -la:drwxr-xr-x 3 1001 123 4096 Jul 23 13:08 .github
##[debug]ls -la:-rw-r--r-- 1 1001 123 793 Jul 23 13:08 .gitignore
##[debug]ls -la:drwxr-xr-x 2 1001 123 4096 Jul 23 13:08 .idea
##[debug]ls -la:drwxr-xr-x 3 1001 123 4096 Jul 23 13:08 benchmarks
##[debug]ls -la:-rw-r----- 1 1001 123 2326 Jul 23 13:08 gha-creds
##[debug]ls -la:drwxr-xr-x 3 1001 123 4096 Jul 23 13:08 modules
##[debug]ls -la:-rw-r--r-- 1 1001 123 1980 Jul 23 13:08 readme.md
##[debug]ls -la:drwxr-xr-x 4 1001 123 4096 Jul 23 13:08 terraform
##[debug]ls -la /github/home:total 8
##[debug]ls -la /github/home:drwxr-xr-x 2 1001 123 4096 Jul 23 13:09 .
##[debug]ls -la /github/home:drwxr-xr-x 6 root root 4096 Jul 23 13:09 ..
##[debug]printenv:GITHUB_WORKSPACE=/github/workspace
##[debug]printenv:INPUT_BACKEND_CONFIG_FILE=
##[debug]printenv:CHECKPOINT_DISABLE=true
##[debug]printenv:HOSTNAME=d1
##[debug]printenv:TF_IN_AUTOMATION=true
##[debug]printenv:GITHUB_PATH=/github/file_commands/add_path_1
##[debug]printenv:GITHUB_ACTION=__dflook_terraform-apply
##[debug]printenv:CLOUDSDK_CORE_PROJECT=project1
##[debug]printenv:GOOGLE_CLOUD_PROJECT=project1
##[debug]printenv:INPUT_VAR_FILE=terraform/input.tfvars
##[debug]printenv:
##[debug]printenv:GITHUB_RUN_NUMBER=9
##[debug]printenv:RUNNER_NAME=GitHub Actions 2
##[debug]printenv:GITHUB_REPOSITORY_OWNER_ID=1
##[debug]printenv:RUNNER_DEBUG=1
##[debug]printenv:GITHUB_TRIGGERING_ACTOR=DawidNiezgodka
##[debug]printenv:runner_ip=1.2.3.4
##[debug]printenv:GITHUB_REF_TYPE=branch
##[debug]printenv:WORKSPACE_TMP_DIR=.dflook-terraform-github-actions/efcnphjj
##[debug]printenv:ACTIONS_CACHE_URL=https://artifactcache.actions.githubusercontent.com/
##[debug]printenv:***
##[debug]printenv:INPUT_TARGET=
##[debug]printenv:GITHUB_REPOSITORY_ID=123
##[debug]printenv:GITHUB_ACTIONS=true
##[debug]printenv:GOOGLE_APPLICATION_CREDENTIALS=/github/workspace/gha-creds
##[debug]printenv:INPUT_PATH=terraform
##[debug]printenv:GITHUB_SHA=sha
##[debug]printenv:GITHUB_WORKFLOW_REF=DawidNiezgodka/Repo1/.github/workflows/test_benchmark.yml@refs/heads/new-structure
##[debug]printenv:INPUT_VAR=
##[debug]printenv:RUNNER_ENVIRONMENT=github-hosted
##[debug]printenv:TF_PLUGIN_CACHE_DIR=/usr/local/share/terraform/plugin-cache
##[debug]printenv:GITHUB_REF=refs/heads/new-structure
##[debug]printenv:INPUT_BACKEND_CONFIG=
##[debug]printenv:RUNNER_OS=Linux
##[debug]printenv:GITHUB_REF_PROTECTED=false
##[debug]printenv:HOME=/github/home
##[debug]printenv:GITHUB_API_URL=https://api.github.com
##[debug]printenv:CLOUDSDK_METRICS_ENVIRONMENT=github-actions-setup-gcloud
##[debug]printenv:ACTIONS_ID_TOKEN_REQUEST_TOKEN=***
##[debug]printenv:RUNNER_ARCH=X64
##[debug]printenv:RUNNER_TEMP=/home/runner/work/_temp
##[debug]printenv:ACTIONS_RUNTIME_URL=https://pipelines.actions.githubusercontent.com/
##[debug]printenv:INPUT_PARALLELISM=0
##[debug]printenv:GITHUB_STATE=/github/file_commands/save_state_1
##[debug]printenv:GITHUB_ENV=/github/file_commands/set_env_1
##[debug]printenv:GITHUB_EVENT_PATH=/github/workflow/event.json
##[debug]printenv:GITHUB_EVENT_NAME=push
##[debug]printenv:INPUT_REPLACE=
##[debug]printenv:GITHUB_RUN_ID=5636
##[debug]printenv:INPUT_AUTO_APPROVE=true
##[debug]printenv:INPUT_VARIABLES=runner_ip=1.2.3.4
##[debug]printenv:gha_workspace=/home/runner/work/Repo1/Repo1
##[debug]printenv:
##[debug]printenv:GITHUB_STEP_SUMMARY=/github/file_commands/step_summary_
##[debug]printenv:GITHUB_ACTOR=DawidNiezgodka
##[debug]printenv:INPUT_LABEL=
##[debug]printenv:CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=/github/workspace/
##[debug]printenv:GITHUB_RUN_ATTEMPT=2
##[debug]printenv:TFMASK_RESOURCES_REGEX=(?i)^(random_id|kubernetes_secret|acme_certificate).*$
##[debug]printenv:GOOGLE_GHA_CREDS_PATH=/github/workspace/gha-creds
##[debug]printenv:GITHUB_GRAPHQL_URL=https://api.github.com/graphql
##[debug]printenv:STEP_TMP_DIR=/tmp
##[debug]printenv:ACTIONS_RUNTIME_TOKEN=***
##[debug]printenv:GITHUB_SERVER_URL=https://github.com
##[debug]printenv:GCLOUD_PROJECT=project1
##[debug]printenv:CLOUDSDK_PROJECT=project1
##[debug]printenv:SHLVL=0
##[debug]printenv:GITHUB_ACTOR_ID=2283
##[debug]printenv:RUNNER_TOOL_CACHE=/opt/hostedtoolcache
##[debug]printenv:CLOUDSDK_METRICS_ENVIRONMENT_VERSION=1.1.1
##[debug]printenv:GITHUB_WORKFLOW_SHA=***
##[debug]printenv:GITHUB_REF_NAME=new-structure
##[debug]printenv:TF_INPUT=false
##[debug]printenv:GITHUB_JOB=continuous_benchmarking
##[debug]printenv:INPUT_WORKSPACE=default
##[debug]printenv:ACTIONS_ID_TOKEN_REQUEST_URL=***
##[debug]printenv:GITHUB_REPOSITORY=DawidNiezgodka/Repo1
##[debug]printenv:GITHUB_RETENTION_DAYS=90
##[debug]printenv:RUNNER_WORKSPACE=/home/runner/work/Repo1
##[debug]printenv:GITHUB_ACTION_REPOSITORY=dflook/terraform-apply
##[debug]printenv:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
##[debug]printenv:GITHUB_BASE_REF=
##[debug]printenv:GCP_PROJECT=project1
##[debug]printenv:CI=true
##[debug]printenv:GITHUB_REPOSITORY_OWNER=DawidNiezgodka
##[debug]printenv:GITHUB_HEAD_REF=
##[debug]printenv:GITHUB_ACTION_REF=v1
##[debug]printenv:JOB_TMP_DIR=/github/home/.dflook-terraform-github-actions
##[debug]printenv:GITHUB_WORKFLOW=Continuous Benchmarking
##[debug]printenv:GITHUB_OUTPUT=/github/file_commands/set_output_0f3f290
##[debug]printenv:INPUT_DESTROY=false
##[debug]git config --list:credential.helper=/usr/bin/git-credential-actions
##[debug]git config --list:credential.usehttppath=true
::group::Installing Terraform
Installing Terraform
::group::Initializing Terraform
Initializing Terraform
##[debug] terraform workspace select default
Error: Path does not exist: "terraform/input.tfvars"
##[debug]ls -la /github/workspace:total 44
##[debug]ls -la /github/workspace:drwxr-xr-x 8 1001 123 4096 Jul 23 13:08 .
##[debug]ls -la /github/workspace:drwxr-xr-x 6 root root 4096 Jul 23 13:09 ..
##[debug]ls -la /github/workspace:drwxr-xr-x 8 1001 123 4096 Jul 23 13:08 .git
##[debug]ls -la /github/workspace:drwxr-xr-x 3 1001 123 4096 Jul 23 13:08 .github
##[debug]ls -la /github/workspace:-rw-r--r-- 1 1001 123 793 Jul 23 13:08 .gitignore
##[debug]ls -la /github/workspace:drwxr-xr-x 2 1001 123 4096 Jul 23 13:08 .idea
##[debug]ls -la /github/workspace:drwxr-xr-x 3 1001 123 4096 Jul 23 13:08 benchmarks
##[debug]ls -la /github/workspace:drwxr-xr-x 3 1001 123 4096 Jul 23 13:08 modules
##[debug]ls -la /github/workspace:drwxr-xr-x 4 1001 123 4096 Jul 23 13:09 terraform
##[debug]Finishing: Terraform apply
Do you have any idea what might be wrong?
I can't reproduce this problem. Are you certain terraform/input.tfvars exists? Can you trying checking it exists as part of the workflow, e.g.:
- name: Check vars
run: cat terraform/input.tfvars
When one facepalm is not enough.
I had this same issue (using Nektos Act as well). In my case, it ended up being an entry in my .gitignore
to ignore .tfvars
files.
Problem description
I can't execute the
terraform apply
command because the action claims that the variable file does not exist.Here's the simplified output of the
tree
command:I tried both
terraform/input.tfvars
andinput.tfvars
, but none of them works. I tried running it locally withact
and remotely on GitHub - same result.Terraform version
1.5.3
Backend
gcs
Workflow YAML
Workflow log