Migrate GitLab CI from deprecated Terraform templates to OpenTofu
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, opentofu_version, root_dir, and state_name, with TF_STATE_NAME set to match.
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.
Context: 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.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.