Skip to content

feat(emitter): add support for HCL expression AST nodes in module calls#5

Merged
glucaci merged 1 commit intomainfrom
extend-api
Apr 12, 2026
Merged

feat(emitter): add support for HCL expression AST nodes in module calls#5
glucaci merged 1 commit intomainfrom
extend-api

Conversation

@glucaci
Copy link
Copy Markdown
Member

@glucaci glucaci commented Apr 12, 2026

This pull request adds support for setting Terraform module input variables using HCL AST expressions, enabling more flexible and accurate emission of complex, multi-line HCL values. It introduces a new overload for ModuleCallBuilder.Set that accepts an HclExpression, updates the HCL emission logic to handle multi-line values with correct indentation, and exposes a utility for emitting any HCL expression as a canonical string. Comprehensive tests and documentation are included to demonstrate and validate these new capabilities.

Core API Enhancements:

  • Added a new overload Set(string name, HclExpression expression) to ModuleCallBuilder, allowing variables to be set using HCL AST nodes for complex or multi-line values. [1] [2]
  • Exposed a new public static method ModuleCallEmitter.EmitExpression(HclExpression expression) to emit any HCL AST node as a canonical HCL string. [1] [2]

HCL Emission Improvements:

  • Improved the emission of multi-line HCL values in module blocks: continuation lines are now properly indented to align under the first value character, ensuring correct and readable output for nested objects, tuples, and for-expressions.

Testing:

  • Added extensive unit tests for the new Set(HclExpression) overload and for the EmitExpression method, covering variable references, function calls, literals, objects, tuples, for-expressions, and multi-line formatting. [1] [2]

Documentation:

  • Updated and expanded the documentation in terraformdotnet.md to describe the new features, including usage examples and explanations for setting variables from HCL AST expressions and emitting expressions standalone.

@glucaci glucaci merged commit b03e9f9 into main Apr 12, 2026
1 check passed
@glucaci glucaci deleted the extend-api branch April 12, 2026 08:17
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