Skip to content
Latchkey

Terramate "generated code is outdated" (generate drift) in CI

Terramate generates Terraform (backend, provider, and other blocks) from its config. A CI check runs terramate generate --detailed-exit-code (or --check) and fails when the committed generated files drift from what the current config would produce.

What this error means

A Terramate CI step fails reporting that generated code is outdated, or that generation produced changes, meaning the committed files were not regenerated after a config change.

terramate
error: generated code is outdated

please run 'terramate generate' and commit the changes

Common causes

Config changed without regenerating

A generate_hcl/generate_file block or its inputs changed, but the generated Terraform was not re-run and committed.

Generated files edited by hand

Someone edited a generated file directly; Terramate would overwrite it, so the check flags the drift.

How to fix it

Regenerate and commit

  1. Run terramate generate locally.
  2. Commit the regenerated files.
  3. Push so the CI check passes.
Terminal
terramate generate
git add . && git commit -m "regenerate terramate code"

Gate generation in CI

Keep the check so drift fails fast and the regenerate lands with the config change.

Terminal
terramate generate --detailed-exit-code

How to prevent it

  • Run terramate generate whenever generate blocks or inputs change.
  • Never hand-edit generated files.
  • Keep the generate check in CI so drift is caught in review.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →