Terraform plan output artifact not created

Summary

Terraform plan output file is seemingly ignored when running within the gitlab runner. The same command correctly produces the output file when ran locally.

Steps to reproduce

.gitlab-ci.yml
terraform_plan:
  stage: plan
  script:
    - TF_LOG=DEBUG terraform plan -out plan -var "vpc_id=$DEV_VPC_ID"
  only:
    refs:
      - master
    changes:
      - dev/data-storage/redis/*
  artifacts:
    paths:
      - plan
  tags:
    - eks-runner

Actual behaviour

  • The usual plan output as shown in the expected behaviour section is completely missing. Hence the plan artifact cannot be found:
Uploading artifacts for successful job
00:00
Uploading artifacts...
WARNING: plan: no matching files                   
ERROR: No files to upload                          
Job succeeded

Expected behaviour

------------------------------------------------------------------------

This plan was saved to: plan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan"

Relevant logs and/or screenshots

  • Using TF_LOG=DEBUG I found the following output about the plan but this is the only mention.
2020/10/14 16:32:02 [INFO] backend/local: writing plan output to: plan

Environment description

  • private gitlab runners installed using the helm chart.
  • gitlab-runner 13.0.0
  • Kubernetes executor
  • image: hashicorp/terraform:0.13.4

Used GitLab Runner version

Running with gitlab-runner 13.0.0 (c127439c)
  on gitlab-runner-gitlab-runner-7b749886c7-nmx78 bQdxkS6m
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab-runner
Using Kubernetes executor with image hashicorp/terraform:0.13.4 ...
Edited by James Downing