Skip to content

Commit

Permalink
fix: Handle non-location bound resources in region rotator (#881)
Browse files Browse the repository at this point in the history
## Description

<!--Why this PR? What is changed? What is the effect? etc.

If you haven't already, read the full [contribution
guide](https://github.com/Azure/bicep-registry-modules/blob/main/CONTRIBUTING.md).
The guide may have changed since the last time you read it, so please
double-check. Once you are done and ready to submit your PR, edit the PR
description and run through the relevant checklist below.

Enable GitHub Workflows in your fork to enable auto-generation of assets
with our [GitHub Action](/.github/workflows/push-auto-generate.yml).
To trigger GitHub Actions after auto-generation, [add a GitHub
PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
as a secret in your forked repository called `PAT`.
-->

Update the the PowerShell script to handle null resource locations (e.g
`consumption/budgets` returns `[]` to `Get-AzResourceProvider`)

## Testing


[![avm.res.consumption.budget](https://github.com/ChrisSidebotham/bicep-registry-modules/actions/workflows/avm.res.consumption.budget.yml/badge.svg?branch=csidebotham%2Fnon-loc-resource-handling)](https://github.com/ChrisSidebotham/bicep-registry-modules/actions/workflows/avm.res.consumption.budget.yml)

[![avm.res.network.dns-zone](https://github.com/ChrisSidebotham/bicep-registry-modules/actions/workflows/avm.res.network.dns-zone.yml/badge.svg?branch=csidebotham%2Fnon-loc-resource-handling)](https://github.com/ChrisSidebotham/bicep-registry-modules/actions/workflows/avm.res.network.dns-zone.yml)
  • Loading branch information
ChrisSidebotham authored Jan 30, 2024
1 parent a24f695 commit 10aa23e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Get-AzAvailableResourceLocation {
$ResourceRegionList = (Get-AzResourceProvider | Where-Object { $_.ProviderNamespace -eq $formattedResourceProvider }).ResourceTypes | Where-Object { $_.ResourceTypeName -eq $formattedServiceName } | Select-Object -ExpandProperty Locations
Write-Verbose "Region list: $($resourceRegionList | ConvertTo-Json)"

if ($resourceRegionList -eq "global") {
if ($resourceRegionList -eq "global" -or $null -eq $resourceRegionList) {
Write-Verbose "Resource is global, default region [$GlobalResourceGroupLocation] will be used for resource group creation"
$location = $GlobalResourceGroupLocation # Set Location to resource group location. Globabl resources should have hardocded location in `main.bicep`
}
Expand Down

0 comments on commit 10aa23e

Please sign in to comment.