简体   繁体   中英

Moving terraform configuration files into separate directory removes them from the plan

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.

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.

Terraform Modules

EDIT: I also found an really similar question What is the correct way to setup multiple logically organized sub folders in a terraform repo?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM