Hi,
I am responsible for setting/creating infra for the company and I am trying to introduce IaC approaches at the company. I am looking for ways and recommendations on how should I structure the terraform repository.
Infrastructure requirements can be categorized into two requirements, project specific and ad hoc requests. Example of project specific requirements could be something like, I need to set up a data platform for the company, a data platform would comprise of multiple infra components, like it would need glue, redshift database, roles to run glue jobs etc etc. Example of adhoc requests is like creating a new ec2 instance for small PoC or sharing access to a consultant for limited time etc etc.
^This is generally the type of requests I get, so based on this I am planning to implement this following directory structure.
- applications
- data-platform
- glue_role.tf
- glue.tf
- redshift.tf
- some-other-application/
- ad-hoc
- ec2.tf
- user-management
- roles.tf
- user-groups.tf
- policies.tf
- modules
- iam_role
- main.tf
- variables.tf
- outputs.tf
- ec2
- main.tf
- variables.tf
- outputs.tf
main.tf
I also have to maintain three environments, dev, stage and prod. For environments I am thinking to use workspaces, so if I want to apply to prod, I should switch to prod workspace.
The main.tf
file in the root, acts as an entrypoint for terraform command and it imports all other modules and directories (i.e. it imports data-platform
).
In your experience, does this approach sounds correct and scalable? I will have other people also working on this, so I am also using s3 as a backend.