Within the AWS VME-R team, we employ IaC to build and maintain our infrastructure using tools such as Terraform by HashiCorp.
Using Terraform, the infrastructure for an application can be quickly created, updated, destroyed, and recreated based on a known configuration that is version controlled.
We also use Terraform Workspaces, which is a feature of Terraform. This allows Terraform to use something called a state file, this saves the state of any given environment, such as production, development and test environments.
Using these Workspace state files allows Terraform to have different configurations. We can use the same Terraform code, but have slightly different configurations for each environment, rather than having to duplicate all the Terraform code for each environment.
For example, if we were to create several virtual machines for development, we would change Terraform to use the development workspace, and make changes to the configuration of these virtual machines. Then, when we apply the changes, this will only affect the development state file, and only make changes to the development environment.
The same would be true if switching to the test workspace, where we could have a completely different configuration, but using one set of Terraform configuration code.
Following this approach allows the re-use of the same Terraform code, but with specific variables for either workspace, rather than duplicating code for multiple environments, and having to maintain this code.
The key benefit of having your Infrastructure as Code is that there is no configuration creep. Everything is documented, it is created exactly the same every time, the code is in a stable known working state, and is re-usable by other projects.