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

refactor(misconf): improve Terraform scanning logging #7133

Closed
wants to merge 2 commits into from

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Jul 9, 2024

Description

Removed noisy messages. Some messages have been added and changed:

2024-07-09T21:58:18 07:00       DEBUG   [misconf] terraform.parser.<root>.evaluator Failed to expand block "aws_subnet.public_subnet". Invalid "for-each" argument: cty.NilVal. Must be known and iterable.

Also removed duplicate time from the message.
Before:

2024-07-09T15:18:08Z    DEBUG   [misconf] 18:08.884431133 terraform.parser.<root>.evaluator Starting module evaluation...

After:

2024-07-09T21:58:18 07:00       DEBUG   [misconf] terraform.parser.<object>.evaluator Starting module "object" evaluation

Related Issues:

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@nikpivkin nikpivkin marked this pull request as ready for review July 10, 2024 06:17
@nikpivkin nikpivkin requested a review from simar7 as a code owner July 10, 2024 06:17
@simar7 simar7 added this pull request to the merge queue Jul 10, 2024
@simar7 simar7 removed this pull request from the merge queue due to a manual request Jul 10, 2024
@@ -296,6 307,8 @@ func (e *evaluator) expandBlockForEaches(blocks terraform.Blocks, isDynamic bool
forEachVal := forEachAttr.Value()

if forEachVal.IsNull() || !forEachVal.IsKnown() || !forEachAttr.IsIterable() {
e.debug.Log(`Failed to expand block %q. Invalid "for-each" argument: %s. Must be known and iterable.`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to this, should we also do a further check to make sure that the terraform configuration we just parsed, is valid? This is in reference to #7099 (comment)

In the above case, I think we should we also log the fact that we purposely ignored an invalid terraform configuration file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by valid configuration? Syntactically or valid for evaluation? In the first case we return an error, in the second case I think the notion of invalid does not fit here, rather incomplete. We may lack some data to evaluate individual blocks and dependencies, not the whole configuration. This can happen mostly because of missing input data or using data blocks or resources that are not static (e.g. random provider).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by valid configuration?

I meant this case: #7099 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added logging if the user has not set the variable 1febd97

@nikpivkin
Copy link
Contributor Author

Closed in favour of #7295

@nikpivkin nikpivkin closed this Aug 13, 2024
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

Successfully merging this pull request may close these issues.

bug(misconf): Inconsistent in the issue count If terraform variables are not passed
2 participants