Hello,
I am trying to populate my network_acls.ip_rules
for my azurerm_key_vault
based on the GitHub runners IP Address from the Github /meta
API. I have managed to grab the data I need by using a http
data resource but I need to filter it based on the IPV4 addresses since the API calls comes with IPV6 addresses as well and terraform throws a fit if I attempt to pass those in…
Here is what I attempted:
network_acls {
default_action = "Deny"
bypass = "AzureServices"
ip_rules = jsondecode( data.http.github_metadata.body ).actions
}
I get this error: network_acls.0.ip_rules.793 must start with IPV4 address and/or slash, number of bits (0-32) as prefix. Example: 127.0.0.1/8. Got "2a01:111:f403:f90c::/62".
I have attempted to use a for
loop and a regexall
on the list but I am not getting any changes when I attempt a terraform plan
or terraform plan
…
network_acls {
default_action = "Deny"
bypass = "AzureServices"
ip_rules = [ for ipaddress in jsondecode( data.http.github_metadata.body ).actions : ipaddress if regexall("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(3[0-2]|[1-2][0-9]|[0-9]))$", ipaddress) == 0 ]
}
If anyone has solved this problem before, I would greatly appreciate the help