Creating multiple instances of a module


I’m new to terragrunt and am a little confused over how you would create multiple instances of a module for a given environment.

Let’s say, for example, that I have a module like the one in the terragrunt mysql example, but I need to create multiple databases per aws environment.

From what I can tell, the only way to do this is to either:

a) Create a new directory for each database instance I want, or
b) Create a new module that accepts all of the same inputs, but with a loop counter to iterate over an array of inputs

Is there a better way to handle this?


You usually have a single module in your infrastructure-modules to which you refer to in your infrastructure-live as many times as needed. So you’ll likely end up with a single module directory, with multiple live directories.

Check out the following blog post for a good explanation: