Get specific directory name

I’m trying to find a way to force directory names as a way to manage dependencies. I know there is a dependencies function, but it isn’t dynamic.

I have this folder

And I want it to require and also depend on this folder/file


Trying to find some combination of this to put in the primary tfvars

extra_arguments "dependencies" {
  commands           = ["${get_terraform_commands_that_need_vars()}"]
  required_var_files = ["${get_parent_tfvars_dir()}/global/iam/service_roles/${get_tfvars_dir()}/terraform.tfvars"]

Hi jparfitt,

We don’t have a lot of functionality in the terragrunt built in functions that provide path manipulation, so to do what you want using pure terragrunt functions would most likely require enhancing the interpolations with another function that supports common path manipulations like basename or dirname.

That said, we recently implemented an escape hatch of sorts in the form of a run_cmd interpolation function (introduced in v0.18.2). This allows you to call out to an external program and replace the value with the stdout of the call. You can use this to implement a shell script that returns what you want (e.g in your example, the device name) given the current path.

Does that help?