Protecting Terraform Code Collaboration and Version Control

Best Practices for Collaborative Terraform Code Development

Question

You are responsible for creating and modifying the Terraform templates that define your Infrastructure.

Because two new engineers will also be working on the same code, you need to define a process and adopt a tool that will prevent you from overwriting each other's code.

You also want to ensure that you capture all updates in the latest version.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

The best option in this scenario is option B:

B. Store your code in a Git-based version control system. Establish a process that includes code reviews by peers and unit testing to ensure integrity and functionality before integration of code. Establish a process where the fully integrated code in the repository becomes the latest master version.

Explanation:

Storing the code in a Git-based version control system is a common best practice in modern software development. It allows developers to work collaboratively and maintain a history of changes over time. Git provides features for version control, collaboration, and merging of code changes. It also allows multiple developers to work on the same codebase without overwriting each other's changes.

In addition to storing code in Git, it is important to establish a process that ensures code quality and prevents errors. The process should include code reviews by peers and unit testing to ensure the integrity and functionality of the code before it is integrated. This helps to catch any errors or issues before they are deployed to production.

The final step is to establish a process for promoting code to the latest master version. Once the code has been reviewed, tested, and approved, it can be merged into the main branch of the repository. The latest version should always reflect the fully integrated code in the repository.

Option A is not as comprehensive as option B because it only recommends merging changes at the end of each day without mentioning code reviews or testing. It also suggests packaging and uploading code to a versioned Cloud Storage basket as the latest master version, which is not an appropriate way to manage version control.

Option C is not a good choice because it recommends storing code as text files in Google Drive, which is not a version control system. It also suggests renaming the folder structure with a predefined naming convention that increments the version, which is not a scalable or efficient approach.

Option D is also not a good choice because it recommends storing code in Google Drive and creating a new .zip archive with a predefined naming convention every day. This is not a sustainable way to manage version control and does not include code reviews or testing. It also suggests accepting the .zip archive as the latest version, which is not a best practice for managing code changes.