Solution skill
Migrate GitLab CI from deprecated Terraform templates to OpenTofu
Complete solution
Shows how to fix migrate GitLab CI from deprecated Terraform templates to OpenTofu. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Replace the deprecated Terraform template includes with the OpenTofu component: include a component reference to gitlab.com/components/opentofu/validate-plan-apply at a pinned version, passing inputs for version, opentofuversion, rootdir, and statename, with TFSTATE_NAME set to match.
Steps
- Replace the deprecated Terraform template includes with the OpenTofu component: include a component reference to gitlab.com/components/opentofu/validate-plan-apply at a pinned version, passing inputs for version, opentofuversion, rootdir, and statename, with TFSTATE_NAME set to match. Define validate, build, and deploy stages to match what the component expects; mismatched stage names are what break the naive conversion. Note the SAST-IaC template path is a separate unsolved problem in the thread, so keep SAST on its own track.
When to use
You are seeing this: Define validate, build, and deploy stages to match what the component expects; mismatched stage names are what break the naive conversion. Use this skill when you run into "Migrate GitLab CI from deprecated Terraform templates to OpenTofu".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Note the SAST-IaC template path is a separate unsolved problem in the thread, so keep SAST on its own track.
Evidence
Source: Stack Overflow #78061859 (top answer, 5 votes): the Terraform CI/CD templates for GitLab were deprecated, and the asker hit errors converting a basic pipeline to OpenTofu. The self-verified fix uses the official GitLab OpenTofu component instead of the old templates.
Verified resolution: Replace the deprecated Terraform template includes with the OpenTofu component: include a component reference to gitlab.com/components/opentofu/validate-plan-apply at a pinned version, passing inputs for version, opentofuversion, rootdir, and statename, with TFSTATE_NAME set to match. Define validate, build, and deploy stages to match what the component expects; mismatched stage names are what break the naive conversion. Note the SAST-IaC template path is a separate unsolved problem in the thread, so keep SAST on its own track.
Source URL: https://stackoverflow.com/questions/78061859/migrate-gitlab-ci-yml-from-terraform-to-opentofu
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_fwuGCZFoTKKUg2VMPuCOZg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Migrate GitLab CI from deprecated Terraform templates to OpenTofu <span>— Vectle</span></a>