Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to organize some kind of resources in subdirectories #618

Closed
chenrui333 opened this issue Dec 7, 2018 · 5 comments
Closed

How to organize some kind of resources in subdirectories #618

chenrui333 opened this issue Dec 7, 2018 · 5 comments
Labels

Comments

@chenrui333
Copy link
Contributor

Right now I have resources sitting in one level (one module), as the resource files in the module grow, I can imagine it would helpful to have the resource files sitting in the subdirectories grouped by different reasons.

For example, currently resource files layout is like below

.
├── resource1.tf
├── resource2.tf
├── resource2.tf
├── main.tf
└── terraform.tfvars

I want to transform into something like this

.
├── project1
│   ├── resource1.tf
│   ├── resource2.tf
├── project2
│   ├── resource3.tf
│   ├── resource4.tf
├── main.tf
└── terraform.tfvars

Let me know if this does make sense. Thanks!

@brikis98
Copy link
Member

This sounds like more of a Terraform question than a Terragrunt question. See, for example, Terraform Modules, How to create reusable infrastructure with Terraform modules, and terragrunt-infrastructure-live-example.

@chenrui333
Copy link
Contributor Author

yeah, but the terraform state files managed is per module, right. I am think if we can manage the tf-state files per directory?

Also, the module is more for the homogeneous resources, the sources in my directory could be different from one to the other.

@brikis98
Copy link
Member

State is managed by Terragrunt, it's managed by Terraform, which does it on a per-folder basis. If you're breaking up your infrastructure just to make the code easier to read and follow, then create a bunch of small Terraform modules, and use the module keyword to import them into a single module that ultimately gets deployed with one state file. If you're breaking up the infrastructure to isolate different environments or types of infrastructure from each other, then you'll want to isolate the state files too.

@chenrui333
Copy link
Contributor Author

@brikis98 thanks for the response, I will need to think about a better way to structure my question

@yorinasub17
Copy link
Contributor

Closing as this is primarily a Terraform question as opposed to Terragrunt. Please follow hashicorp/terraform#26177. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants