You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposal
I think that it would be really useful if Terragrunt supported an interpolation function called split(). It would be very similar to Terraform's split() and may work something like this:
split(string, delimiter, index): Splits the input string along the delimiter
character into a list of substrings and returns the
substring at the requested index.
The reason to accept an index in this function is to prevent the need for Terragrunt to support the list type in interpolations (correct that Terragrunt does not support the list type in interpolations, right?). If list type was supported, then you could remove the index param and just do split("a/b/c", "/")[0].
You'd need appropriate escaping on the delimiter character, error handling, etc, etc.
Motivation
I am currently working on an example for #169 which demonstrates how to setup your directory hierarchy when trying to work with a single account and multiple regions. I am trying to figure out the best way to keep the configuration DRY in terms of passing the correct region to the Terraform modules. I see that there is a lot of discussion in #132 and #147 about this same question, but I could not see an approach that works yet (please share if I just missed it).
One idea I had to solve the same issue was to rely on the convention of my directory hierarchy to pull the name of the correct region. For example, the directory hierarchy might look like:
This is a clever idea. The key question is whether this would still be useful if we implemented something like read_var_from_file? Chances are, you'll have to define the region to deploy into in your .tfvars file anyway (e.g. to pass to the AWS provider), so it would make sense to reuse that value explicitly.
Proposal
I think that it would be really useful if Terragrunt supported an interpolation function called
split()
. It would be very similar to Terraform's split() and may work something like this:The reason to accept an index in this function is to prevent the need for Terragrunt to support the list type in interpolations (correct that Terragrunt does not support the list type in interpolations, right?). If list type was supported, then you could remove the index param and just do
split("a/b/c", "/")[0]
.You'd need appropriate escaping on the delimiter character, error handling, etc, etc.
Motivation
I am currently working on an example for #169 which demonstrates how to setup your directory hierarchy when trying to work with a single account and multiple regions. I am trying to figure out the best way to keep the configuration DRY in terms of passing the correct region to the Terraform modules. I see that there is a lot of discussion in #132 and #147 about this same question, but I could not see an approach that works yet (please share if I just missed it).
One idea I had to solve the same issue was to rely on the convention of my directory hierarchy to pull the name of the correct region. For example, the directory hierarchy might look like:
and then the top level
terraform.tfvars
file could look like:The interpolations would resolve to:
A similar approach could be used to also pull the correct account ID from the directory hierarchy when working with multiple AWS accounts.
Thoughts?
The text was updated successfully, but these errors were encountered: