I’m working on creating a pipeline for terraform, init, fmt, validate, plan, apply … and I’m struggling a little bit at the plan phase of this.
We have a large terraform source tree that essentially has one openstack instance per directory…
What I’m stumbling on now is that I have a script that traverses our large terraform source tree… finds all of the files that were changed, processes each directory in which those files are found… does an init, fmt, validate and if that succeeds, it does a terraform plan -out ${instance_name} …
The problem is that when the plan stage goes to collect the artifacts that I’ve told it to upload… it says they dont existing the directory I’ve specified…
This is my .gitlab-ci.yml … redacted a bit.
stages:
- validate
- plan
image: hashicorp/terraform:1.3.7
before_script:
- apk update
- apk --no-cache add bash ca-certificates curl jq
- |-
cat <<EOF >~/.terraformrc
credentials "<gitlab-fqdn>" {
token = "${CI_TF_TOKEN}"
}
EOF
validate:
stage: validate
script:
- bash ci-scripts/lint.sh
- bash ci-scripts/validate.sh
plan:
stage: plan
script:
- bash ci-scripts/plan.sh
dependencies:
- validate
artifacts:
paths:
- plan-*
I tried specifying various paths in the plan.sh script, such as /tmp and /root … last attempt, I just dropped in whatever PWD was set to in the job… still no luck. Every time, it says something like this:
Uploading artifacts...
++ /usr/bin/gitlab-runner-helper artifacts-uploader --url https://<gitlab-fqdn>/ --token [MASKED] --id 30021 --path 'plan-*' --artifact-format zip --artifact-type archive
WARNING: plan-*: no matching files
ERROR: No files to upload
Can someone clue me in as to what I’m missing?