Using multiple modules / remote state

modules
terraform-state
terragrunt

#1

Hi there,

I new to Terragrunt and keen to give it a go - something I couldn’t see by reading the GitHub page is if you’re able to use multiple modules when writing a plan… or is the idea to separate each component into it’s own module with it’s own state file?

On that note, I didn’t see examples of using using the remote state / outputs from another plan, is that possible with Terragrunt? e.g. can I create a VPC and have another plan use it’s id output?


#2

Yes, you can use multiple modules. You share state/outputs between them using the terraform_remote_state data source and Terragrunt even supports running commands across multiple modules.


#3

Hi @jim

How does the remote state data source work within terragrunt? Can we specify the data block within the Terragrunt section of the tfvars file or does it need to be contained within the module itself with the values interpolated into the tfvars file?

I am trying to use remote with a module imported from the Terraform registry (of which I cannot get working with before/after hooks, so having to have a seperate .tf file within my plan directory with the provider and backend statements).


#4

Hi @mcalry,

Specifying remote state configuration isn’t limited just to the module itself, you can also specify it in the tfvars file. Take a look at the documentation here: https://github.com/gruntwork-io/terragrunt#path_relative_to_include

Cheers
Toni