Skip to content

Migrate from Terraform templates to OpenTofu components

Problem statement

On GitLab 18.0 the Terraform templates that we are using in the deployment project will be deprecated. The deprecation will take effect due to changes in the Terraform license.

Proposed solution

We can replace the Terraform template with the OpenTofu Gitlab component. We can follow the migration guide provided in the OpenTofu Gitlab component project.

Related links

Implementation plan

  • Update handbook list of upstream tools by including the opentofu component version and opentofu version.
  • Use gitlab.com/components/opentofu/job-templates instead of terraform template
  • Configure the Opentofu component to point to the correct state_name and root_dir
  • Migrate fmt job. We should have a fmt job for all envs
  • Migrate validate job. We should have a validate job for all envs
  • Refactor existing build dev and build prod in smaller jobs
  • Migrate build job to use opentofu
  • Refactor existing push images dev and push images prod in one job named push images and use parallel jobs
  • Refactor existing deploy dev and deploy prod in smaller jobs
  • Migrate deploy job to use opentofu
  • Migrate destroy-dev to use opentofu.
  • Add instructions on how to install opentofu and update apply.sh
  • Update Readme if needed
  • Update all other docs

Testing

  • You can test all migrated jobs in a MR pipeline
  • Test deploy commands first on your local environment and then on dev and finally on prod.

Improvements

  • Use OpenTofu instead of Terraform
  • Reduce the pipelines length by using parallel jobs speeding up dev efforts
Edited by Nick Ilieskou