Skip to content

Conversation

@Emyrk
Copy link
Member

@Emyrk Emyrk commented Jun 30, 2025

Description

Let me know if I am missing some other means to make this work

evaluateStep handles many terraform semantics such as default values for 'variables'. A hook into these steps allows defining additional semantics, likely to mirror those of the actual provider implementation.

This must be done in evaluateStep, as things such as expandBlocks occur afterwards. Without this hook, the ExpandBlock must be called manually outside of the executor.

data "your_custom_data" "this" {
  default = ["a", "b", "c"]
}

data "random_thin" "that" {
  dynamic "repeated" {
    for_each = data.your_custom_data.this.value
    content {
      value = repeated.value
    }
  }
}

Conversation

Calling ExpandBlock outside is ok, however I wonder if calling EvaluateStep again is required in order to be correct. EvaluateSteps is called here after ExpandBlocks

https://github.com/aquasecurity/trivy/blob/main/pkg/iac/scanners/terraform/parser/evaluator.go#L145

Hence why this hook was added. To place similar semantic code to variable defaults in the same spot.

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).

evaluateStep handles many terraform semantics such as default
values for 'variables'. A hook into these steps allows defining
additional semantics, likely to mirror those of the actual provider
implementation.
@Emyrk Emyrk closed this Aug 7, 2025
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.

1 participant