Terraform Version
G'day, I've found on terraform 0.12.x that a module within a module won't be detected during plan and will be silently ignored until terraform init is run, rather than failing plan like a top-level module does.
Terraform Configuration Files
$ cat target/target.tf
resource "null_resource" "test" {
provisioner "local-exec" {
command = "true"
}
}
module "mod" {
source = "../module"
}
$ cat module/module.tf
resource "null_resource" "mod_test" {
provisioner "local-exec" {
command = "true"
}
}
$ cat submod/submod.tf
resource "null_resource" "submod_test" {
provisioner "local-exec" {
command = "true"
}
}
If you initialise the above structure, and then modify module/module.tf like so without re-initing:
$ cat module/module.tf
resource "null_resource" "mod_test" {
provisioner "local-exec" {
command = "true"
}
}
module "submod" {
source = "../submod"
}
Expected behaviour
Error: Module not installed
on module.tf line 7:
7: module "submod" {
Actual behaviour
$ terraform plan
# ...
Terraform will perform the following actions:
# null_resource.test will be created
+ resource "null_resource" "test" {
+ id = (known after apply)
}
# module.mod.null_resource.mod_test will be created
+ resource "null_resource" "mod_test" {
+ id = (known after apply)
}
Plan: 2 to add, 0 to change, 0 to destroy.
$ terraform init
# ...
$ terraform plan
# ...
Terraform will perform the following actions:
# null_resource.test will be created
+ resource "null_resource" "test" {
+ id = (known after apply)
}
# module.mod.null_resource.mod_test will be created
+ resource "null_resource" "mod_test" {
+ id = (known after apply)
}
# module.mod.module.submod.null_resource.submod_test will be created
+ resource "null_resource" "submod_test" {
+ id = (known after apply)
}
Plan: 3 to add, 0 to change, 0 to destroy.
Terraform Version
G'day, I've found on terraform 0.12.x that a module within a module won't be detected during
planand will be silently ignored untilterraform initis run, rather than failingplanlike a top-level module does.Terraform Configuration Files
If you initialise the above structure, and then modify
module/module.tflike so without re-initing:Expected behaviour
Actual behaviour