fix: use native azurerm attribute for ACR task network bypass - #142
Open
sry9681 (sry9681) wants to merge 1 commit into
Open
fix: use native azurerm attribute for ACR task network bypass#142sry9681 (sry9681) wants to merge 1 commit into
sry9681 (sry9681) wants to merge 1 commit into
Conversation
The azapi_update_resource added in Azure#102 sets networkRuleBypassAllowedForTasks on a registry that azurerm_container_registry also manages. azurerm 4.81.0 added network_rule_bypass_for_tasks_enabled as optional and non-computed, so leaving it unset means the provider reverts the azapi value on every plan. Set the attribute natively and drop the azapi workaround. Requires azurerm >= 4.81.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview/Summary
azapi_update_resource.network_rule_bypass_allowed_for_tasks(added in #102) setsnetworkRuleBypassAllowedForTaskson a registry thatazurerm_container_registry.alzalso manages.azurerm
4.81.0addednetwork_rule_bypass_for_tasks_enabledtoazurerm_container_registry. In the provider schema it isoptional = true, computed = false, so leaving it unset means "use the schema default", not "leave the existing value alone". The provider therefore reverts what azapi wrote, and every subsequent plan against a private networking deployment shows:Applying that reverts the bypass. With
public_network_access_enabled = falsethis is the flag the build task relies on to reach the registry, so image builds are at risk.This sets the attribute natively and removes the azapi workaround.
This PR fixes/adds/changes/removes
network_rule_bypass_for_tasks_enabled = var.use_private_networkingonazurerm_container_registry.alz.azapi_update_resource.network_rule_bypass_allowed_for_tasksand its reference in theazurerm_container_registry_task_schedule_run_now.alzdepends_on. Ordering is preserved implicitly, since the task run already depends on the task, which depends on the registry.modules/azure/terraform.tffrom~> 4.20to~> 4.81.Breaking Changes
The azurerm minimum moves to
4.81.0. Verified by schema inspection that4.80.0and earlier do not exposenetwork_rule_bypass_for_tasks_enabled, so the constraint bump is required rather than optional.Existing deployments are not modified.
azapi_update_resourcedestroy is a state only operation, and the azurerm resource asserts the same value, so the registry is left as is.Testing Evidence
Tested against a deployed bootstrap using self hosted runners with private networking, where the registry already carried the flag set by the current code.
Registry state before, showing the azapi value in place:
{ "publicAccess": "Disabled", "bypassOption": "AzureServices", "bypassForTasks": true, "sku": "Premium" }Plan on the current
main, showing the reverting diff:Plan on this branch, against the same state and the same registry:
0 to changeconfirms the diff is resolved. The single destroy is the azapi resource leaving state; the registry itself is untouched.terraform validatepasses andmake fmtreports no further changes.As part of this Pull Request I have
mainbranch