Hello guys,
Since that we started to develop and add some terraform code into our project, I think that it might be a good time for us to discuss the file structure and some base guidelines to help us out.
There are two start points that I would like to discuss here and be free to add something else:
- File structure using terraform modules.
- Documentation (using
terraform-docs, I will explain it).
File structure
TL;DR; this is the file structure proposed:
root
|-- terraform -> root directory for our terraform code
| README.md -> index file with the list of all modules and reference for their docs. Also any extra info and guidance
|-- modules -> root directory for all modules created (VPC, ECR, SSM, etc.)
|-- module1
|-- README.md -> each module should have it - how to use it, what are the inputs and outputs variables
|-- main.tf
|-- module2
|-- README.md
|-- main.tf
|-- examples -> root directory (or playground directory) to demonstrate how the modules are used which also serves for testing
|-- module1
|-- main.tf
|-- module2
|-- main.tf
|-- prod -> root directory for our production environment, here will use the modules to create our cloud environment
|-- main.tf
@mfreitassm used this file structure in her PR #17, and it is also proposed by the terraform guidelines, so no, I don't have any credits for it. 😆
Right, now give me some reason. 😒
-
We will have some tasks which depend on other tasks. Like, we will need to create the SSM parameters and ECR to do the task WordPress - ECS Task and Service. So we will need to look at our peer work and play with that to conclude our task. Of course, we could annoy them every time but they might be busy with something else or might not have time to help you at the moment.
-
It is modular, so it is replicable, we could create different environments for testing, staging, production. Just add a new folder and start to pick up your modules as you pick up your favourite fruits (or candy) in your grocery store. (Also we will comply with one of our project requirements from our lovely project owner).
-
The example folder is extra, but I like that idea to have some examples there to how to use the code for our teammates have to look at it. It will also be useful for testing, if you add/update something, we could modify the example one without need to set all the parameters again and again.
That is it, for now, I will repeat, I will love to hear your thoughts about it.
Documentation
Short story: So here I am thinking of how I can be more lazy I can make my life easier and automate some boring but essential task (DOCUMENTATION). So, surfing 🏄 in the internet, terraform-docs comes to rescue me and generate amazing markdown documents with all the input/output variables. On top of that, it is customizable and can be automated.
If you read the short story above, great, if not. I would like to present terraform-docs. It is a simple tool that you can install in your system and from the terraform code location, and it will read your files and generate documentation in various output formats.
It can be automated with a short script to generate/update the documents for all our modules at a glance. We could add it in the GitHub actions in the future. I actually wrote a small script (more like copy from the terraform-docs page) and create a root makefile to call the script. I will send a PR late if everyone agrees with that.
I just used it in my recent PR, so you guys can have a lot at its output. It is simple to use, I can explain it better if you want, but you should have a try. If you don't like to install, just run it as a container to check it out ;)
Give me your feedback

So, guys, I would like to know what do you think about that. Give any answer between:
- Fantastic, let's do it
- Hmm, I like it, but maybe we could
express your opinion here
- I hate it !
- You are crazy !!
- What hell are you talking about ??
Hello guys,
Since that we started to develop and add some terraform code into our project, I think that it might be a good time for us to discuss the file structure and some base guidelines to help us out.
There are two start points that I would like to discuss here and be free to add something else:
terraform-docs, I will explain it).File structure
TL;DR; this is the file structure proposed:
Right, now give me some reason. 😒
We will have some tasks which depend on other tasks. Like, we will need to create the SSM parameters and ECR to do the task
WordPress - ECS Task and Service. So we will need to look at our peer work and play with that to conclude our task. Of course, we could annoy them every time but they might be busy with something else or might not have time to help you at the moment.It is modular, so it is replicable, we could create different environments for testing, staging, production. Just add a new folder and start to pick up your modules as you pick up your favourite fruits (or candy) in your grocery store. (Also we will comply with one of our project requirements from our lovely project owner).
The example folder is extra, but I like that idea to have some examples there to how to use the code for our teammates have to look at it. It will also be useful for testing, if you add/update something, we could modify the example one without need to set all the parameters again and again.
That is it, for now, I will repeat, I will love to hear your thoughts about it.
Documentation
If you read the short story above, great, if not. I would like to present terraform-docs. It is a simple tool that you can install in your system and from the terraform code location, and it will read your files and generate documentation in various output formats.
It can be automated with a short script to generate/update the documents for all our modules at a glance. We could add it in the GitHub actions in the future. I actually wrote a small script (more like copy from the terraform-docs page) and create a root makefile to call the script. I will send a PR late if everyone agrees with that.
I just used it in my recent PR, so you guys can have a lot at its output. It is simple to use, I can explain it better if you want, but you should have a try. If you don't like to install, just run it as a container to check it out ;)
Give me your feedback
So, guys, I would like to know what do you think about that. Give any answer between:
express your opinion here