Enabled KeyVault to the test framework and align pattern.
Summary
This merge request refactors and enhances the configuration, variables, and testing for multiple Azure modules (app-insights, keyvault, log-analytics). These changes address simplification of resource attributes, improved modularity, and better testing coverage.
Key Changes
app-insights Module
-
Modified
test.shScript:- Renamed variables in
.tfvarscontent:-
appinsights_name→name -
service_plan_resource_group_name→resource_group_name - Added a new
locationparameter.
-
- Simplified default resource tags to
osdu = "module".
- Renamed variables in
-
Updated
main.tf:- Changed dependency injection:
- No longer relies on a
resource_groupmodule. - Variables
appinsights_name,service_plan_resource_group_name, and others now align with module-level variables (var.name,var.resource_group_name, etc.).
- No longer relies on a
- Removed unnecessary
depends_onfor resource group creation.
- Changed dependency injection:
-
Added Input Variables:
- New variables (
name,resource_group_name,location, andresource_tags) make module configuration explicit and modular.
- New variables (
-
Modified
unit_test.go:- Updated test variables and expected outputs:
-
nameandresource_group_nameare now dynamic for tests. - Resource count decreased for simplified resources.
-
- Tags validation added for app insights resources.
- Updated test variables and expected outputs:
keyvault Module
-
New
test.shScript:- Added a new test script for simplifying Key Vault setup and
.tfvarsgeneration. - Supports environment variable overrides for key vault configuration (e.g.,
KEYVAULT_NAME,PUBLIC_NETWORK_ACCESS,PURGE_PROTECTION).
- Added a new test script for simplifying Key Vault setup and
-
Refactored
main.tf:- Directly references
keyvaultvariables instead of aresource_groupmodule. - Introduced modular variables for flexibility:
-
keyvault_name,resource_group_name,resource_tags, etc.
-
- Directly references
-
Revised Variables:
-
public_network_access_enablednow defaults totrue. -
keyvault_purge_protection_enableddefaults changed tofalse. - Added a complete set of tagged inputs for testing and customization.
-
-
Updated
unit_test.go:- Test variable setup now uses
keyvault_nameand dynamic unique IDs. - Ensures correct validation of
tagsandskufor Key Vault resources.
- Test variable setup now uses
log-analytics Module
-
Modified
test.sh:- Restructured
.tfvarscontent for clarity:- Added explicit tagging and refined workspace-specific configurations.
- Format enhancements for better future maintainability.
- Restructured
-
Refactored
main.tf:- Removed dependency on a
resource_groupmodule; now directly usesvar.resource_group_name. - Modularized input parameters (
name,solutions,resource_tags) with default values.
- Removed dependency on a
-
New Input Variables in
main.tf:- Added
solutionsas a list of objects for workspace integrations:- Includes
ContainerInsightsby default configurable through inputs.
- Includes
- Introduced
resource_tagsfor custom tagging.
- Added
-
Updated
unit_test.go:- Test setup now uses dynamic names for the Log Analytics workspace.
- Verifies
retention_in_daysand customtagsfor validated resource configurations.
Technical Details
-
Cross-module Updates:
- Dependency on
resource_groupmodules removed wherever applicable, ensuring clearer abstractions and reduced dependencies. - Input variables now allow dynamic configuration for location, resource tags, and module-specific options.
- Dependency on
-
Testing Enhancements:
- Test fixture refinements focus on dynamic, modular configuration using unique IDs to avoid state conflicts.
- Reduced expected resource count for tests by consolidating unnecessary resources or dependencies.
-
Default Behavior Changes:
- Resources now use consistent default regions (
eastus2) and tagging schemas. - Defensive validations tightened (
keyvault_nameformat checks,boolsettings forPURGE_PROTECTION, etc.).
- Resources now use consistent default regions (