You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Premium ACR is created without problems with one or more ip_rule in network_rule_set.
Actual Behaviour
│ Error: Unknown variable
│
│ on main.tf line 34, in resource "azurerm_container_registry" "acr_premium":
│ 34: for_each = local.acr_allowed_ips
│
│ There is no variable named "local".
If you use external variable and refers it as "var.variablename" it returns same error with note: There is no variable named "var".
Steps to Reproduce
terraform plan
(or terraform apply)
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered:
@lukriv Sorry thay you run into this issue. The reason is because the ip_rule (even the network_rule_set) is defined with ConfigMode: pluginsdk.SchemaConfigModeAttr, which makes it to be an attribute even though it looks like a block in the HCL:
The reason for making it an attribute is to allow users to reset the ip_rule to an empty list by ip_rule = [] syntax. Especially, this is needed for network_rule_set when changing sku from Premium to Basic. But I'm not sure whether we should also do this for the ip_rule. Whilst, we are not able to simply revert it since it will then otherwise breaks the usage of assigning to an empty slice. We can introduce that change in v4.0 though.
I ran into the same issue and managed a bit of a hacky workaround. As mentioned above, ip_rule can be a list, so you can use a for loop to generate ip_rule as a list with multiple rules like this:
network_rule_set {
default_action = "Deny"
ip_rule = [
for ip in local.acr_allowed_ips : {
action = "Allow"
ip_range = ip
}
]
}
The end result works the same way a dynamic block would, and it successfully adds the IP addresses to the ACR firewall rules.
Is there an existing issue for this?
Community Note
Terraform Version
1.3.9
AzureRM Provider Version
3.45.0
Affected Resource(s)/Data Source(s)
azurerm_container_registry
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Premium ACR is created without problems with one or more ip_rule in network_rule_set.
Actual Behaviour
│ Error: Unknown variable
│
│ on main.tf line 34, in resource "azurerm_container_registry" "acr_premium":
│ 34: for_each = local.acr_allowed_ips
│
│ There is no variable named "local".
If you use external variable and refers it as "var.variablename" it returns same error with note: There is no variable named "var".
Steps to Reproduce
(or terraform apply)
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: