Terraform: can we support folders?

Created on 25 Nov 2015  ยท  8Comments  ยท  Source: hashicorp/terraform

i am organizing my .tf files trying to find a way to scan .tf under deeper folders

i think this is a pretty common use case so not sure if i am missing something, i noticed the [dir] argument but i am trying to see if i can pass at least multiple directories as arguments

any hints?

core question

Most helpful comment

Hi @cordoval, actually no you don't need to run terraform get unless you add a new module, or you have a fresh clone of the repository. This is because terraform get uses symlinks in the .terraform/modules directory:

.
โ”œโ”€โ”€ .terraform
โ”‚ย ย  โ””โ”€โ”€ modules
โ”‚ย ย      โ””โ”€โ”€ de20b4a64fe2fcc6b3b57b2c0e1e2b01 -> /Users/James/Code/terraform/mods/module
โ”œโ”€โ”€ main.tf
โ”œโ”€โ”€ module
โ”‚ย ย  โ””โ”€โ”€ main.tf

Hopefully this provides a solution - feel free to reopen if not!

All 8 comments

I am having a script that looks like this so far

#!/usr/bin/env bash
terraform plan \
    ecs
    output
    providers
    registry
    security
    -var-file="secret_vars.tfvars" \
    -var-file="ecs/public_vars.tfvars"

UPDATE but not sure if it is working so far

Hi @cordoval! Currently this isn't supported - though you may be able to make use of the module system to organise your code in the manner you'd like?

@jen20 the problem with modules is that they require to be pulled out from the web or registries, i don't like that, i want everything in subfolders.

They don't need to be pulled out of the web or registries: you can specify the source as a subdirectory of the file system - for example:

module "iam" {
     source = "${path.module}/modules/iam"
}

Does that make them more palatable?

you rock @jen20

it still stores them with terraform get into under .terraform/modules right? so i always have to run terraform get whenever i do any change in them

Hi @cordoval, actually no you don't need to run terraform get unless you add a new module, or you have a fresh clone of the repository. This is because terraform get uses symlinks in the .terraform/modules directory:

.
โ”œโ”€โ”€ .terraform
โ”‚ย ย  โ””โ”€โ”€ modules
โ”‚ย ย      โ””โ”€โ”€ de20b4a64fe2fcc6b3b57b2c0e1e2b01 -> /Users/James/Code/terraform/mods/module
โ”œโ”€โ”€ main.tf
โ”œโ”€โ”€ module
โ”‚ย ย  โ””โ”€โ”€ main.tf

Hopefully this provides a solution - feel free to reopen if not!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings