Skip to content

configs.ModuleCall can have an empty config  #21568

@mildwonkey

Description

@mildwonkey

If a nested sub-module - two modules deep - has a variable with a misspelled attribute, configs will return a module call with no module config. terraform init|plan|apply have no problem with this, but it caused a crash in terraform show -json. It is also of note that terraform validate does not catch this (from the top-level directory) as it does not follow nested modules.

If this isn't causing problems elsewhere it might not be worth changing the behavior; I am opening this issue to capture my findings. My primary concern is for sentinel users.

Terraform Version

v0.12.0

Terraform Configuration Files

$ tree
.
├── main.tf
├── modules
│   ├── main.tf
│   └── more
│       └── main.tf

main.tf:

  module "my_module" {
    source = "./modules"
}

./modules/main.tf:

  module "nested_module" {
    source = "./more"
}

./modules/more/main.tf:

  variable "misspelled" {
    default = "hiya"
    descriptini = "this attribute is misspelled"
}

Expected Behavior

The config loader should either put a placeholder empty body in there, or leave out the ModuleCall entirely, or similar.

Actual Behavior

config was nil

Steps to Reproduce

terraform show -json tf.plan

Additional Context

init and plan all run successfully.

References

#21543

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions