Skip to content

Commit 8d5c6d1

Browse files
fix: remove serverFarmId casing replace that causes perpetual plan diff (#132)
The resource_id output was using replace() to convert Azure's returned 'serverfarms' (lowercase) to 'serverFarms' (uppercase F). This caused perpetual drift for azapi consumers: Azure normalizes the ID back to lowercase on read, so every plan showed a diff. Remove the replace() and output the ID as Azure returns it. This was originally added for issue #129 (azurerm provider ID parsing), but that is a provider limitation that consumers can handle with their own replace() if needed. Closes #131 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7315b22 commit 8d5c6d1

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

avm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ if [ -f "avm.config.json" ]; then
173173
done
174174
fi
175175

176+
# Forward AVM_BARE_* environment variables to the container with the prefix stripped
177+
while IFS='=' read -r bareKey bareValue; do
178+
[ -z "$bareKey" ] && continue
179+
strippedKey="${bareKey#AVM_BARE_}"
180+
export "$strippedKey"="$bareValue"
181+
LOCAL_ENVIRONMENT_VARIABLES="${LOCAL_ENVIRONMENT_VARIABLES}-e $strippedKey "
182+
echo "Forwarding AVM bare variable to container as: $strippedKey"
183+
done < <(env | grep '^AVM_BARE_' || true)
184+
176185
# Check if we are running in a container
177186
# If we are then just run make directly
178187
if [ -z "${AVM_IN_CONTAINER}" ]; then
@@ -199,7 +208,7 @@ if [ -z "${AVM_IN_CONTAINER}" ]; then
199208
-e TF_IN_AUTOMATION=1 \
200209
${LOCAL_ENVIRONMENT_VARIABLES} \
201210
--env-file <(env | grep '^TF_VAR_') \
202-
--env-file <(env | grep '^AVM_') \
211+
--env-file <(env | grep '^AVM_' | grep -v '^AVM_BARE_') \
203212
"${CONTAINER_IMAGE}" \
204213
make \
205214
TUI="${TUI}" \

avm.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,18 @@ if (-not $env:AVM_IN_CONTAINER) {
150150
$dockerArgs += @("-e", "$($_.Name)=$($_.Value)")
151151
}
152152

153-
# Add AVM_ environment variables
154-
Get-ChildItem env: | Where-Object { $_.Name -like "AVM_*" } | ForEach-Object {
153+
# Add AVM_ environment variables (excluding AVM_BARE_* which are forwarded with the prefix stripped)
154+
Get-ChildItem env: | Where-Object { $_.Name -like "AVM_*" -and $_.Name -notlike "AVM_BARE_*" } | ForEach-Object {
155155
$dockerArgs += @("-e", "$($_.Name)=$($_.Value)")
156156
}
157157

158+
# Forward AVM_BARE_* environment variables to the container with the prefix stripped
159+
Get-ChildItem env: | Where-Object { $_.Name -like "AVM_BARE_*" } | ForEach-Object {
160+
$strippedName = $_.Name -replace '^AVM_BARE_', ''
161+
$dockerArgs += @("-e", "$strippedName=$($_.Value)")
162+
Write-Host "Forwarding AVM bare variable to container as: $strippedName"
163+
}
164+
158165
# Add local environment variables from avm.config.json
159166
if (Test-Path "avm.config.json") {
160167
$jsonContent = Get-Content "avm.config.json" -Raw | ConvertFrom-Json -AsHashtable

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ output "name" {
55

66
output "resource_id" {
77
description = "Resource id of the app service plan"
8-
value = replace(azapi_resource.this.id, "Microsoft.Web/serverfarms/", "Microsoft.Web/serverFarms/")
8+
value = azapi_resource.this.id
99
}

0 commit comments

Comments
 (0)