terraform-google-modules / terraform-example-foundation

Shows how the CFT modules can be composed to build a secure cloud foundation
https://cloud.google.com/architecture/security-foundations
Apache License 2.0
1.2k stars 706 forks source link

Modules invoked with missing required parameters #1186

Closed mromascanu123 closed 3 months ago

mromascanu123 commented 4 months ago

TL;DR

When invoking some library modules required parameters not passed. It might work if the declared parameters (in variables.tf of the module) endup by actually not being used for reasons of "example" code or disabled sections. But not sure what is the general opinion regarding this coding practice, which I would abstain to qualify in my own words.

See as an example (among many) the attached screenshot exemplifying a call to project-factory with missing required parameters in 1-org/envs/shared/projects.tf.

Expected behavior

Required parameters with valid values should be passed to the modules requiring them, regardless whether actually being used in a particular instance of a module

Observed behavior

The deployment "seems" to work although with many warnings - can't tell anything about actual vs expected resources being deployed

Terraform Configuration

See screenshot as an example, it is a matter of code not configuration

Terraform Version

terraform version
Terraform v1.6.0
on linux_amd64

Your version of Terraform is out of date! The latest version
is 1.8.0.

Additional information

missing-params

daniel-cit commented 3 months ago

Thanks for your report of this issue.

The Terraform configuration is valid as validated by terraform validate

image

Regarding the list of missing required variables in the screenshot most of then are not part of the project-factory module variable list like admin_email, amount, and api_sa_group among others.

For the ones that are part of the module like domain, they do have a default value

https://github.com/terraform-google-modules/terraform-google-project-factory/blob/v14.0.0/variables.tf#L34C1-L38C2 image

The official Terraform documentation regarding input variables, states that variables with a default value are optional (not required)

image

image

Reported behavior looks like an issue in the the configuration of the VSCode extension for Terraform, possibly related to this issue fix: Work around 'unreliable' input data for Registry modules or a similar one in the terraform-ls extension for VSCode provided by HashiCorp since running terraform validate proves that the configuration is valid.

Updating the VSCode extension for Terraform to use the latest release should be able to solve this issue.

eeaton commented 3 months ago

Thanks Daniel, I agree with this explanation that it looks like a configuration issue on the IDE and not a bug in this repo's code. I'll close this issue, please re-open if there are further concerns.