Skip to content

How do you generate the lockfile?

It's not clear how one is intended to generate a lockfile when using gitlab-terraform.

Running terraform init -backend=false locally won't work:

Error refreshing state: 2 problems:

- Unsupported state file format: The state file could not be parsed as JSON: syntax error at byte offset 1.
- Unsupported state file format: The state file does not have a "version" attribute, which is required to identify the format version.

This is likely because I don't have access to the state file from my system (which is expected).

Running it in CI won't help because the lockfile needs to be committed into the repo.

The documentation kinda skips how you'd deal with this, and the sample repo is actually missing the lockfile (which is a pretty bad practice).