I have my terraform infrastructure defined in many configuration files as below.
- root
-
- data_sources.tf
-
- iam.tf
-
- glue_connections.tf
-
- glue_crawlers.tf
-
- glue_catalog.tf
-
- glue_jobs.tf
-
- provider.tf
-
- storage.tf
-
- vpc.tf
I wanted to organise them a bit by moving the configuration files starting with "glue_" into their own directory.
- root
-
- glue
-
-
- glue_connections.tf
-
-
-
- glue_crawlers.tf
-
-
-
- glue_catalog.tf
-
-
-
- glue_jobs.tf
-
-
- data_sources.tf
-
- iam.tf
-
- provider.tf
-
- storage.tf
-
- vpc.tf
But when I applied the change it removed all of the resources that I moved into the glue directory.
Is there some trick that will allow me to move my configuration files into their own directory without terraform removing/ignoring them?
Note: I am using using terraform cloud.
CodePudding user response:
I think this happen because Terraform ignore what you have in the subfolders, so the resources in the glue
directory will not be created.
Indeed, you can create a module glue
and recall it in the main module.
EDIT: I also found an really similar question What is the correct way to setup multiple logically organized sub folders in a terraform repo?