Skip to content

Conversation

@segraef
Copy link
Owner

@segraef segraef commented Jul 17, 2025

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:

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 modules

Change

Feel free to remove this sample text

Thank you for your contribution !
Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.
List any dependencies that are required for this change.

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update (Wiki)

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • My corresponding pipelines / checks run clean and green without any errors or warnings
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (readme)
  • I did format my code

Copilot AI review requested due to automatic review settings July 17, 2025 01:19
@segraef segraef merged commit 9e15307 into main Jul 17, 2025
1 of 2 checks passed
@segraef segraef deleted the more branch July 17, 2025 01:19
Copy link

Copilot AI left a 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>"
Copy link

Copilot AI Jul 17, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +25
if ($subscriptionId -ne '<subId>') {
Set-AzContext -SubscriptionId $subscriptionId
}
Copy link

Copilot AI Jul 17, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
AdditionalTokens = @{
namePrefix = '<your-prefix>'
TenantId = '<tenantId>'
namePrefix = 'asf3re' # Replace with your prefix
Copy link

Copilot AI Jul 17, 2025

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.

Suggested change
namePrefix = 'asf3re' # Replace with your prefix
namePrefix = $namePrefix # Use the parameterized prefix

Copilot uses AI. Check for mistakes.
TenantId = '<tenantId>'
namePrefix = 'asf3re' # Replace with your prefix
TenantId = '<tenantId>' # Replace with your tenant ID
}
Copy link

Copilot AI Jul 17, 2025

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.

Suggested change
}
}
# 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."
}

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +25
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 ' ')
Copy link

Copilot AI Jul 17, 2025

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.

Suggested change
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 ' ')

Copilot uses AI. Check for mistakes.
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.

2 participants