0

I have 2 projects (git repo). They each have their own terraform files and state.

Now I want these 2 projects to depend on 1 database.

I would like to create a common repo with terraform files to create that database and make my 2 initial projects depend on it.

I know that with a monorepo and terragrunt I can do something like:

dependency "vpc" {
  config_path = "../vpc"
}

but is there a way to do this with multiples git repos (no monorepos).

I'm guessing it can't be done, and I suspect that there would be a problem with the multiple states.

bbigras
  • 1,311
  • 2
  • 17
  • 32

1 Answers1

1

Yes, what you could do is use the state of the common terraform. Make sure you output the database id or something on the common terraform so that you can reference to it.
And then inside your child repos use terraform_remote_state data source.

More info here: https://www.terraform.io/docs/language/state/remote-state-data.html

TheE
  • 328
  • 4
  • 13