Staying DRY Using Terraform Workspaces with GitLab-CI
summary
Demo shows a CI/CD workflow that uses Terraform Workspaces with GitLab-CI to avoid copying env folders by naming state files via workspace interpolation, using an S3 backend that becomes AWS/<workspace>/tfstate. Pipeline sets workspace to commit slug, runs terraform validate and plan, passes a plan artifact to a manual approve job, then applies. Also demonstrates remote state as a data source and an assume-role mapping to run across accounts; the demo deploys resources successfully.
AI-written summary · about
chapters (9)
- 0:00Introduction to speaker
- 1:02Tools and typical sprawl
- 2:52Understanding workspaces
- 3:56Workspace benefits and use cases
- 6:33GitLab CI overview
- 7:19Terraform and GitLab demo
- 11:23Code structure and hooks
- 12:47Best practices and conclusion
- 14:45Q&A session
related talks
27mOptimizing Terraform integration inside GitLab CI/CD pipelines
25mManaging Workspaces With the TFE Provider
26mManage your GitLab Projects with Terraform
41mScale infrastructure operations with HCP Terraform self-service workflows
30mMastering Terraform: A deep dive into essential workflows
38mJourney towards CI/CD
23mFrom requests to resources: Automating HCP Terraform with GitHub issue templates and actions
30mManaging Terraform Cloud With PowerShell
