DEV Community

Discussion on: Best way to make infrastructure by Terraform

Collapse
 
salsalyyy profile image
SalSal

Thank you for answer the questions, was really great help to make my mind clear!
If you could also know your opinion on this as well?
which one is better to create a bunch of s3 buckets for multiple environment? write a module to create them once or use simple module and apply multiple times?

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk • Edited

Do they have the same functionality across these environments (like development, test etc) then you would have 1 S3 module and in your application directory you create the single bucket. It will be named slightly different per environment (include the name environment name, dev, test,prod).

Then in your environment directory you supply the correct naming for each environment, then you have to deploy each of them separate with their respective tfstate file per environment.

That is probably the easiest way to do it and then make sure you store the Terraform state in each environment where it belongs to as well.

To target each of them, you can create profiles in your ./.aws/config file and reference them in the Terraform tfstate and your remote state configuration.

I hope that helps

Thread Thread
 
salsalyyy profile image
SalSal • Edited

Well, there are five buckets at least which will repeat in dev, stage and prod! but as far as they contain their environment name in their name, should be change per environment.