Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
Issue
Fixes #132
Description
This pull request includes significant enhancements to the
Write-TfvarsFile
function in theConfig-Helpers
module. The changes improve the handling of different data types when writing configuration values, ensuring that default values are used when necessary and that the correct format is applied for lists, maps, and objects.Enhancements to
Write-TfvarsFile
function:Improved Handling of List Data Types:
[]
) as needed. (src/ALZ/Private/Config-Helpers/Write-TfvarsFile.ps1
)Added Support for Map Data Types:
map(string)
data types, ensuring that empty maps are represented as{}
and non-empty maps are properly formatted. (src/ALZ/Private/Config-Helpers/Write-TfvarsFile.ps1
)Added Support for List of Objects Data Types:
list(object)
data types, ensuring that empty lists are represented as[]
and non-empty lists are correctly formatted with key-value pairs. (src/ALZ/Private/Config-Helpers/Write-TfvarsFile.ps1
)Tests
Test 1:


With this inputs.yaml:
and this variables.tf:
Will result in this .tfvars:

Test 2:

With the same variables.tf file from example 1 and inputs.yaml file missing declarations for the complex types:
Note: Although the logic to use the default values exists, there is currently an issue $configuration.PSObject.Properties where the defaultvalue is always empty even when a default value exists. Currently something I am looking into further.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.