Skip to content

Commit

Permalink
feat(lab 3): add README
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikFricke committed May 6, 2022
1 parent 0a56db2 commit 5ce16c3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 3-code-structure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Code Structure

We already created some input variables, resources, modules, and outputs. Let's talk about naming conventions and code structure best practices to keep the Terraform stack clean. In general, it's good practice to split up the codebase into multiple files. And again, we shouldn't reinvent the wheel and follow best practices by the community.

[Anton Babenko](https://twitter.com/antonbabenko) wrote an awesome ebook collecting many best practices for Terraform. The [ebook](https://www.terraform-best-practices.com/) is a must-read for every Terraform developer!

Based on the [best practices](https://www.terraform-best-practices.com/code-structure), we should split up the `main.tf` file and introduce two new files:

```sh
touch outputs.tf variables.tf
```

Now, move all outputs into the `outputs.tf` and the input variable into the `variables.tf`. That's it so far!

Please take a few minutes and read the [naming conventions](https://www.terraform-best-practices.com/naming) part in the ebook. It might be helpful to get a better understanding of Terraform in general.

## Next

The [next lab](../4-environments/) covers a very important topic: Instead of just deploying the stack once, we want to deploy the stack for multiple environments. Imagine, we want to have a `staging` and `production` environment, probably with slightly different configurations.

0 comments on commit 5ce16c3

Please sign in to comment.