Enhance Cloud Rule Resource to Preserve Order and Handle Template Removals Correctly
This PR significantly improves the handling of AWS CloudFormation and Azure ARM template associations within the kion_cloud_rule Terraform resource. The changes aim to preserve the order of template entries as specified in the Terraform configuration, ensuring our provider aligns more closely with how our application handles template ordering for Cloud Rules.
Key Changes Include:
1. Schema Modification:
Changed the type definition for aws_cloudformation_templates and azure_arm_template_definitions from TypeSet to TypeList. This alteration ensures that the order of templates is maintained across Terraform operations, reflecting the sequence exactly as specified by users.
2. Resource Creation Update:
Updated the resourceCloudRuleCreate function to directly construct slices of template IDs from the state, replacing the previous method that utilized a generic ID flattening utility. This change is crucial for preserving the order of templates during the creation of cloud rules.
3. Resource Read Adjustment:
Modified the resourceCloudRuleRead function to ensure it appropriately reads and sets the ordered templates into the Terraform state, preventing order inconsistencies between the Terraform state and the actual configuration managed by the API.
4. Utility Functions:
Introduced new utility functions extractCFTandARMTemplateIDs and updateCFTandARMTemplateAssociations to encapsulate the logic for extracting template IDs from the configuration and updating template associations via API calls. This not only tidies the main function logic but also improves the reusability and maintainability of the code.
Enhance Cloud Rule Resource to Preserve Order and Handle Template Removals Correctly
This PR significantly improves the handling of AWS CloudFormation and Azure ARM template associations within the
kion_cloud_rule
Terraform resource. The changes aim to preserve the order of template entries as specified in the Terraform configuration, ensuring our provider aligns more closely with how our application handles template ordering for Cloud Rules.Key Changes Include:
1. Schema Modification:
aws_cloudformation_templates
andazure_arm_template_definitions
fromTypeSet
toTypeList
. This alteration ensures that the order of templates is maintained across Terraform operations, reflecting the sequence exactly as specified by users.2. Resource Creation Update:
resourceCloudRuleCreate
function to directly construct slices of template IDs from the state, replacing the previous method that utilized a generic ID flattening utility. This change is crucial for preserving the order of templates during the creation of cloud rules.3. Resource Read Adjustment:
resourceCloudRuleRead
function to ensure it appropriately reads and sets the ordered templates into the Terraform state, preventing order inconsistencies between the Terraform state and the actual configuration managed by the API.4. Utility Functions:
extractCFTandARMTemplateIDs
andupdateCFTandARMTemplateAssociations
to encapsulate the logic for extracting template IDs from the configuration and updating template associations via API calls. This not only tidies the main function logic but also improves the reusability and maintainability of the code.