I would like to ask what is the best way to organise related terraform resources.
For example.
If you have a use case in which you want to do following things.
Idea is to generate a key and generate a signed url for key file to securely share the key to intended audience only.
Create a google cloud bucket
Create a google service account
Create a google service account key
Upload the service account key in bucket
create a signed url for the key file that was uploaded
upload the signed url file in bucket.
Now My question is what is the best way to organise this use case ?
is it good to put all in one file ? something like generate_signed_url.tf
or should be scattered across multiple files like ?
I don’t have experience with Google Cloud and Terraform best practices, but I have built a big deployment of many clouds in AWS using Terraform and after many iterations I have some best practices:
Use modules (your own modules)
Use a single file for each kind of resource (as you are proposing)
Have vars files for each kind of resource
Follow a naming standard for files, vars and values, add tags
Think big, a single cloud can become many and include hundreds of elements
There are many best practices around the Internet that you can follow, if you want to take a look at my best practices see the following post and download the code from github.