Terraform tree structure

Hi all, I’m pretty green on TF and need some guidance with directory structure etc. I have a small project that is growing but I am running into issues which i assume are limitations to how im referencing modules/resources.

My TF tree looks like this:

Tree:
├── acm
│ ├── main.tf
│ └── variables.tf
├── cluster1
│ ├── service1
│ │ ├── alb
│ │ │ ├── main.tf
│ │ │ └── variables.tf
│ │ ├── main.tf
│ │ ├── iam
│ │ │ └── role.tf
│ │ └── messaging
│ │ ├── queue.tf
│ │ ├── sns.tf
│ │ ├── sqs.tf
│ │ └── variables.tf
│ ├── main.tf
│ ├── rds
│ │ ├── rds.tf
│ │ └── variables.tf
│ └── variable.tf
├── main.tf
├── variables.tf

Problem:
When I was trying to get the ACM cert ARN and pass it to the ALB that gets created for service1, I cannot reference it in any way.

I assume i need to restructure and rethink how I’m terraforming before it becomes too cumbersome to manage

Heres a github link with the code im working with.
git@github.com:nhatfield/temp-terraform.git

appreciate any guidance, feedback, etc

Thanks

Hi

I like to structure my Terraform infrastructure in a different way and have published a complete example with source code and explanations at my website:

Terraform layout, naming, variables, modules and best practices are quite personal, there are many alternatives that you should certainly consider. The best way to decide is to start using a layout and see how it works for you and your team.

1 Like