-
Notifications
You must be signed in to change notification settings - Fork 1
Add scripts for processing Azure resource groups and analyzing Bicep/… #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…Terraform modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces a comprehensive suite of scripts for automating Azure and AVM (Azure Verified Module) related development tasks. The changes add new bash and PowerShell scripts for repository management, resource analysis, and Azure resource group processing.
- Adds automated analysis capabilities for AVM pattern module usage patterns across Bicep and Terraform ecosystems
- Introduces Azure resource group processing automation with role assignment capabilities
- Provides repository management automation for cloning and updating AVM Terraform repositories
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
Bash/avm_manual_analysis.sh |
New script for analyzing AVM pattern module test and example files to determine usage of native resources vs AVM modules |
PowerShell/Snippets/AVM-ModuleTester.ps1 |
Enhanced AVM module testing script with improved authentication, subscription handling, and dynamic test case discovery |
_in progress/clone-azure-avm-repos.ps1 |
New script for bulk cloning and updating Azure AVM Terraform repositories with GitHub authentication |
_in progress/process-aiml-resource-groups.ps1 |
New script for processing Azure resource groups with specific naming patterns and automating role assignments |
Comments suppressed due to low confidence (2)
_in progress/process-aiml-resource-groups.ps1:9
- The base directory path is hardcoded to a specific user's directory. This should be parameterized or use environment variables to make the script portable across different systems.
# Role assignment parameters
Bash/avm_manual_analysis.sh:34
- The path '/Azure/' is hardcoded, making the script non-portable. Consider accepting this as a parameter or using environment variables to specify the base directory.
terraform_modules=$(ls -d /Azure/terraform-azurerm-avm-ptn*/ 2>/dev/null | wc -l | tr -d ' ')
|
|
||
| # Role assignment parameters | ||
| $roleDefinitionName = "Owner" | ||
| $objectId = "<objectId>" |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The objectId parameter contains a placeholder value that could be accidentally deployed to production. Consider using parameter validation or environment variables to ensure this value is properly set before execution.
| if ($subscriptionId -ne '<subId>') { | ||
| Set-AzContext -SubscriptionId $subscriptionId | ||
| } |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subscription ID contains a placeholder value that could be accidentally used in production. Consider using parameter validation or configuration files to ensure this value is properly set.
| if ($subscriptionId -ne '<subId>') { | |
| Set-AzContext -SubscriptionId $subscriptionId | |
| } | |
| if ($subscriptionId -eq '<subId>') { | |
| Write-Output "Error: Subscription ID is not set. Please provide a valid Azure subscription ID." | |
| $subscriptionId = Read-Host -Prompt "Enter your Azure subscription ID" | |
| } | |
| Set-AzContext -SubscriptionId $subscriptionId |
| AdditionalTokens = @{ | ||
| namePrefix = '<your-prefix>' | ||
| TenantId = '<tenantId>' | ||
| namePrefix = 'asf3re' # Replace with your prefix |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The namePrefix is hardcoded to a specific value. This should be parameterized to make the script reusable across different environments and users.
| namePrefix = 'asf3re' # Replace with your prefix | |
| namePrefix = $namePrefix # Use the parameterized prefix |
| TenantId = '<tenantId>' | ||
| namePrefix = 'asf3re' # Replace with your prefix | ||
| TenantId = '<tenantId>' # Replace with your tenant ID | ||
| } |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tenant ID contains a placeholder value that could be accidentally used in production. Consider using parameter validation or secure configuration methods.
| } | |
| } | |
| # Validate TenantId | |
| if ($TestModuleLocallyInput.AdditionalTokens.TenantId -eq '<tenantId>') { | |
| throw "Error: TenantId is set to the placeholder value '<tenantId>'. Please replace it with your actual tenant ID." | |
| } |
| bicep_modules=$(ls -d /Azure/bicep-registry-modules/avm/ptn/*/* 2>/dev/null | wc -l | tr -d ' ') | ||
| echo "Total Bicep pattern modules: $bicep_modules" | ||
|
|
||
| # Count Bicep files | ||
| bicep_total=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" 2>/dev/null | wc -l | tr -d ' ') | ||
| echo "Total Bicep TEST files analyzed: $bicep_total" | ||
|
|
||
| # Count files with native resources | ||
| bicep_native_files=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" -exec grep -l "resource.*'Microsoft\." {} \; 2>/dev/null | wc -l | tr -d ' ') | ||
| echo "Test files with native Microsoft resources: $bicep_native_files" | ||
|
|
||
| # Count files with AVM modules | ||
| bicep_avm_files=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" -exec grep -l "module.*'br/public:avm\|module.*'br:mcr\.microsoft\.com.*avm" {} \; 2>/dev/null | wc -l | tr -d ' ') |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path '/Azure/bicep-registry-modules' is hardcoded, making the script non-portable. Consider accepting this as a parameter or using environment variables to specify the base directory.
| bicep_modules=$(ls -d /Azure/bicep-registry-modules/avm/ptn/*/* 2>/dev/null | wc -l | tr -d ' ') | |
| echo "Total Bicep pattern modules: $bicep_modules" | |
| # Count Bicep files | |
| bicep_total=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" 2>/dev/null | wc -l | tr -d ' ') | |
| echo "Total Bicep TEST files analyzed: $bicep_total" | |
| # Count files with native resources | |
| bicep_native_files=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" -exec grep -l "resource.*'Microsoft\." {} \; 2>/dev/null | wc -l | tr -d ' ') | |
| echo "Test files with native Microsoft resources: $bicep_native_files" | |
| # Count files with AVM modules | |
| bicep_avm_files=$(find /Azure/bicep-registry-modules/avm/ptn -path "*/tests/*" -name "*.bicep" -exec grep -l "module.*'br/public:avm\|module.*'br:mcr\.microsoft\.com.*avm" {} \; 2>/dev/null | wc -l | tr -d ' ') | |
| bicep_modules=$(ls -d "${BICEP_BASE_DIR:-/Azure/bicep-registry-modules}/avm/ptn/*/*" 2>/dev/null | wc -l | tr -d ' ') | |
| echo "Total Bicep pattern modules: $bicep_modules" | |
| # Count Bicep files | |
| bicep_total=$(find "${BICEP_BASE_DIR:-/Azure/bicep-registry-modules}/avm/ptn" -path "*/tests/*" -name "*.bicep" 2>/dev/null | wc -l | tr -d ' ') | |
| echo "Total Bicep TEST files analyzed: $bicep_total" | |
| # Count files with native resources | |
| bicep_native_files=$(find "${BICEP_BASE_DIR:-/Azure/bicep-registry-modules}/avm/ptn" -path "*/tests/*" -name "*.bicep" -exec grep -l "resource.*'Microsoft\." {} \; 2>/dev/null | wc -l | tr -d ' ') | |
| echo "Test files with native Microsoft resources: $bicep_native_files" | |
| # Count files with AVM modules | |
| bicep_avm_files=$(find "${BICEP_BASE_DIR:-/Azure/bicep-registry-modules}/avm/ptn" -path "*/tests/*" -name "*.bicep" -exec grep -l "module.*'br/public:avm\|module.*'br:mcr\.microsoft\.com.*avm" {} \; 2>/dev/null | wc -l | tr -d ' ') |
This pull request introduces several new scripts to automate and analyze Azure-related tasks. The changes include scripts for analyzing AVM pattern module usage, testing AVM modules, cloning Terraform repositories, and processing Azure resource groups. Below is a summary of the most significant changes grouped by theme.
AVM Pattern Module Analysis:
Bash/avm_manual_analysis.sh: Added a Bash script to analyze how AVM pattern module tests and examples use resources, including generating statistical summaries and markdown tables for both Bicep and Terraform ecosystems.AVM Module Testing:
PowerShell/Snippets/AVM-ModuleTester.ps1: Enhanced the AVM module tester script by adding Azure authentication checks, updating subscription handling, and modifying test cases to include deployment tests.PowerShell/Snippets/AVM-ModuleTester.ps1: Updated the test case loop to dynamically retrieve test cases from directories when "all" is specified, improving flexibility for module testing.Repository Management:
_in progress/clone-azure-avm-repos.ps1: Added a PowerShell script to clone or update all Terraform AVM repositories from the Azure GitHub organization, including authentication checks and handling of existing directories.Resource Group Processing:
_in progress/process-aiml-resource-groups.ps1: Introduced a PowerShell script to iterate through Azure resource groups with a specific prefix, list resources, and assign roles to external groups, with support for custom operations.…Terraform modulesChange
Feel free to remove this sample text
Type of Change
Please delete options that are not relevant.
Checklist