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

Grace handle of /dev/null when destroying modules #295

Open
darwin67 opened this issue Nov 22, 2023 · 2 comments
Open

Grace handle of /dev/null when destroying modules #295

darwin67 opened this issue Nov 22, 2023 · 2 comments

Comments

@darwin67
Copy link

darwin67 commented Nov 22, 2023

Hi, I realized that when attempting to delete a terragrunt module by setting the source to /dev/null, this script will fail with the following error.

Error: Failed to read module directory: Module directory /dev/null does not exist or cannot be read.

Which is not technically wrong since that is a black hole and you can't read from it.

The problem is, because terragrunt doesn't have a good way to detect destroy attempts when deleting a directory, we need to do this kind of hack.
gruntwork-io/terragrunt#433 (comment)

While uncommon, when I need to mass destroy resources with this method, atlantis.yaml can't be generated due to the previous error.

Would be nice if you could detect that it's targeting /dev/null and in those cases, maybe skip and move on?

Don't have specific solutions in mind so happy to get suggestions too.

@the-nando
Copy link

Have you tried pointing the source to any other directory other than /dev/null? That should work. I use this to toggle deletion / destruction of a module, where get_path_to_repo_root() doesn't contain any TF module:

terraform {
  source = local.destroy ? "${get_path_to_repo_root()}" : "${get_path_to_repo_root()}//modules/my_module"
}

@darwin67
Copy link
Author

darwin67 commented Dec 2, 2023

Huh, interesting. I'll give it a try!

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

No branches or pull requests

2 participants