terragrunt-infrastructure-live-example icon indicating copy to clipboard operation
terragrunt-infrastructure-live-example copied to clipboard

.yml files no loger supported ?

Open ep4sh opened this issue 5 years ago • 7 comments
trafficstars

Accordingly commit I see you have deleted all .yml files, could you please explain is it best practice to use them for variables?

ep4sh avatar Mar 11 '20 13:03 ep4sh

.yml is still supported and can be used, but with the introduction of read_terragrunt_config, you can also use .hcl for that purpose. The benefit of using hcl over yaml is that yaml is a static data language, so you don't have any support for computations and processing over the data. With hcl, you have access to all the functions terragrunt supports, and the ability to compose locals to construct more complex expressions. We feel that this is going to be a more extensible practice than using yaml, and thus we switched our examples over. That said, it really comes down to personal preference: both are valid formats for this purpose and you should use whichever feels better.

yorinasub17 avatar Mar 11 '20 15:03 yorinasub17

Thanks for this answer, could you please also tell, read_terragrunt_config and import are similar functions? I try to create GLOBAL vars in terragrunt.hcl and retrieve them in module's terragrunt.hcl How can I realize it?

ep4sh avatar Mar 12 '20 13:03 ep4sh

The feature you are looking for is the import block which just completed the design cycle, but is not implemented yet. See the RFC for more details: https://github.com/gruntwork-io/terragrunt/blob/master/_docs/rfc/imports.md

yorinasub17 avatar Mar 12 '20 13:03 yorinasub17

So at the moment, I cant do it simply with read_terragrunt_config, I mean I can read child config, but nor the parent, right?

ep4sh avatar Mar 13 '20 14:03 ep4sh

You can read the parent as well, but you can't have cycles. That is, you can't have the child read the parent to expose child vars to the parent, while simultaneously having the child read the parent to get the parent vars.

yorinasub17 avatar Mar 13 '20 15:03 yorinasub17

Can I define the parent list/map/list of maps value (on the root level) and then refine it (on env level)? For e.g. in terrafrunt.hcl:

locals {

vpc_list = {
  vpc_a = "vpc_bla1",
  vpc_b = "vpc_bla2",
}

}

In the env.hcl:

locals {
vpc_name = "vpc_a"
vpc_id = local.vpc_list[vpc_name]
}

I tried to do that but getting error that "value cannot be evalueted"..

ep4sh avatar Mar 23 '20 16:03 ep4sh

Unfortunately, that is not supported. locals are local to the configuration that defined it (that's why they are called "local", as opposed to "global") and are not automatically merged across includes, due to the complexity of implementing a cross configuration references of locals.

yorinasub17 avatar Mar 24 '20 05:03 yorinasub17