How many statefiles

Hi All,

We have currently created a library which interacts with CDKTF and planning to expose it to other libraries which will have actual infra declarations.

We are confused to keep only one repo with all code and single statefile, or keep different repos fro different logical componencts like networking, databases, infrastructure, containerised applications and hence multiple state files.

Which way you are using and which is the suggested way?

There is no right or wrong answer for how many state files to use or how to split things.

Having everything in one place can be simpler, but does mean you can only do a single deployment at a time, and is likely to be pretty slow (depending on the number of resources you have). Also, some actions might not be possible in a single state/set of code (for example deploying settings within a Kubernetes cluster that is just created by Terraform).

How you split things depends on how you work and what you have. Common ideas are splitting by different products or environments, different tiers of a stack, by who owns different areas (where you have multiple teams) and cadancies (so resources which change all the time are split from “base” things which pretty much never change).