| output.tf | ||
| README.md | ||
| variables.tf | ||
Learning and Development: Terraform Cloud with VCS Flow
- Author: Apache X692 Attack Helicopter
- Created on: 14/06/2024
Workflow
Creating Workspace
The first step is to create a workspace in the Terraform Cloud console. Ensure you already have a organization and project created before creating a workspace. An organization is a container for projects and a project is a container for grouping all workspaces. A workspace is the smallest unit of Terraform Cloud which holds the state of a Terraform module/project/config.
Defining Workspace Type
The second step is to choose the type of workspace. There are three type of workspaces in Terraform. They are:
- VCS-driven Workflow
- CLI-driven Workflow
- API-driven Workflow
We're going with the VCS-driven workflow here.
Triggering Workflows
A Terraform plan action is run on the configuration when the repository has a push, pull request and a merge. Terraform provides an option to apply the changes to the infrastructure if the plan generation is successful. However, we've disabled it for this project. Note that for a pull request alone, only plan generation is made. You can review the plan generation and upon successful review, you can proceed with a merge.
Merge Triggering
Another plan generation is done automatically by Terraform Cloud after you merge. This is because multiple developers are working on the same project and hence it is necessary to regenerate the plan with the merged configuration. You can again review it (for manual apply) and confirm changes.
References
- Terraform Workspace: https://app.terraform.io/app/santhosh010303/workspaces/lad-terraform-cloud-vcs
- Terraform Documentation for VSC Workflow: https://developer.hashicorp.com/terraform/tutorials/cloud-get-started/cloud-vcs-change