|
|
|
|
|
by mdaniel
847 days ago
|
|
heh, terraform is just ... special resource "nomad_job" "terrareg" {
jobspec = <<EOHCL
job "terrareg" {
but to be actually constructive, a fun trick is that one can patch this stanza in via the GL pipeline and thus allow local $(tofu plan) runs without needing, or running the risk of, live gitlab credentials variables:
# Backend required for Gitlab state
BACKEND_TF: |
terraform {
backend "http" {
}
}
before_script:
- echo "$BACKEND_TF" > backend.tf
it may also interest this audience that due to gitlab's in-container shell detection scheme, often a better entrypoint override is entrypoint: ["/usr/bin/env"] (assuming such a thing exists, of course) |
|
That's a good idea for the backend - thank you!
And yes, I should have used the used a separate HCL file for the nomad_job - aside from being cleaner, it would have also avoided some horrific JSON encode that I had to use for an environment variable (think: `env { blah = eplace("\"", "\\\"", jsonencode(local.something))`), since I could just pass the jsonencode value straight to the value of the parameter, rather than getting Terraform to convert it to a string for the template.