Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuously deploying terraform script with Gi...

Continuously deploying terraform script with Gitlab CI.

This talk introduces how to use Gitlab CI to manage complex terraform codebases with ease.

Idowu Emehinola

April 12, 2022
Tweet

More Decks by Idowu Emehinola

Other Decks in Programming

Transcript

  1. Site Reliability Engineer at Westwing HashiCorp Certified: Terraform Associate AWS

    Community Builders (Container) he/him @_hydeenoble Idowu Emehinola
  2. Terraform Terraform is an open-source infrastructure as code software tool

    that provides a consistent CLI workflow to manage hundreds of cloud services. Terraform codifies cloud APIs into declarative configuration files.
  3. Terraform Modules A terraform module can be seen as a

    folder that contains multiple resources that are used together. Modules can be used to create lightweight abstractions, so that you can describe your infrastructure in terms of its architecture, rather than directly in terms of physical objects.
  4. Terraform Workspaces Terraform workspaces allow you to manage different environments

    for your infrastructure without having to duplicate your configuration files in separate folders. For example, if you have one cloud project per environment (development, staging, production), terraform workspace can help you manage the resources for each project in a seamless way so that each project will get the same configuration without sharing any resources.
  5. CODE EDITOR Medium-siz ed terraform codebase. Infrastructure for different environments

    would be managed using terraform workspace. . ├── main.tf ├── modules │ └── module-1 │ ├── main.tf │ ├── outputs.tf │ └── variables.tf ├── outputs.tf └── variables.tf 2 directories, 6 files
  6. CODE EDITOR Large-sized terraform codebase. Infrastructure for different environments would

    be managed using terraform workspace. . ├── applications │ ├── app-1 │ │ ├── main.tf │ │ ├── outputs.tf │ │ └── variables.tf │ └── app-2 │ ├── main.tf │ ├── outputs.tf │ └── variables.tf └── modules └── module-1 ├── main.tf ├── outputs.tf └── variables.tf 5 directories, 9 files
  7. Gitlab CI Stages Terraform Validate This gitlab CI stage tries

    to check if terraform codebase configuration is valid. Terraform format check. This gitlab CI stage tries to recursively check if the terraform codebase configuration is in standard style. Terraform Apply This gitlab CI stage attempts to create or update infrastructure. Terraform Plan. This gitlab CI stage shows changes required by the current configuration
  8. Summary In summary, gitlab CI can be easily configured to

    deploy very complex terraform scripts. 05