2
votes

I've been following this particular blog post as a guide.

https://blog.gruntwork.io/how-to-manage-terraform-state-28f5697e68fa

So I understand the need to have state files per environment but is anyone going the extra length and using a state file per component? For example, we have modules for our application stack. To keep this example simple, let's say I have two modules.

App1 - contains a LAMP stack

App2 - LAMP stack plus rabbitmq and redis

Each environment (dev, uat and prod) would have both app stack. Would you have a state file for each component, giving you 6 state files?

1

1 Answers

0
votes

I've used this method in the past - I had 3 separate components and 3 different environments. The different components had different rates of change and some dependencies between then so I used a remote state datasource to share output variables between them.

The biggest problem with this approach is the management overhead of maintaining the different environments/components.

An alternative could be to use different components in conjuction with workspaces