terragrunt icon indicating copy to clipboard operation
terragrunt copied to clipboard

Terragrunt does not check if there is TF file in terraform source block

Open badsector3 opened this issue 2 years ago • 2 comments

Terragrunt version: 0.38.4

When I reference Terraform source to path which exists but there are not any TF files - Terragrunt will run the script saying: "No changes. Your infrastructure matches the configuration."

locals {
  env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
  name     = "test"
}

terraform {
  source = "[email protected]:..//modules/cam?ref=v1.11.0"
}

inputs = {
  new_user            = true
}

Having directory structure such:

- modules
  - cam
     - users
     - policies

and adding source as above - Terragrunt will not complain and output is:

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Acquiring state lock. This may take a few moments...

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
Releasing state lock. This may take a few moments...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Very missliding and 1st time not easy to find. I would expect Terragrunt to through Error or Warning that no TF files can be found under CAM directory. Modules and TF files are one level below in users and policies directories.

Not sure if that is bug or not but definitely something to look into IMO.

badsector3 avatar Jul 12 '22 15:07 badsector3

This would be expected behavior to me as terragrunt only fires the terraform command in that directory so terraform would have to decide the behavior of throwing an warning/error. Implementing like a pre-check would be a new feature. Not sure if it would be a nice-to-have thing for terragrunt. I'd suggest to forward this issue to the terraform project.

Btw which terraform version are you using?

maunzCache avatar Jul 13 '22 06:07 maunzCache

I tried with Terraform version 1.2.3 and 1.2.4. Can you provide link to Terraform once you open case with them please? Thanks

badsector3 avatar Jul 13 '22 08:07 badsector3