Best practice structure for deploying services separately?

We have multiple services that we would like to deploy separately using Terraform Cloud. They do share resources such as a VPC.

Any recommendations on how we can best achieve them deploying separately? Some ideas that come to mind for me are:

  1. We could have them all in one Terraform repository, as different modules. However, I’m not sure if we’d be able to deploy the services separately because I believe they’d share one state file at the home directory level.
  2. We could break them into separate, standalone Terraform repositories. This solves the separate deployment use case, but how do we share resources like a VPC?
  3. Other recommendations?

Thanks in advance! :slight_smile:

I would use option 2.

To link things together you can use remote state and/or datasources.

Depends on how large your asset list is, and how often something changes (and how many). For most Infrastructure as code projects, you’re better off breaking things apart and just having a bunch of separate state files (IMHO), that would mean smaller compare and execution cycles on a “normal” basis.

If something massive is going to change, then you’ll spend more time updating different repos, but you would have to do that anyway with a large repo, so any time savings don’t add up.