Iām doing a refactor of our terraform. In the existing code, this works fine (excerpt). It creates an approle with no bound cidrs.
inputs.tf:
standard_apps = [
{
"app_name" : "test_app"
"auth" : [{
"auth_path" : "approle_auth"
"valid_boundaries" : ["prod", "dev"]
}]
"create_shared" : true
"engine_types" : ["kv-v2"]
},
approle_auth_entities.tf
locals {
approle_auth_roles = {
for reader in local.readers :
reader.app_boundary => reader if reader.auth_path == "approle_auth"
}
secret_auth_roles = {
for reader in local.readers :
reader.app_boundary => reader if reader.auth_path == "approle_auth" && reader.bind_secret_id != false
}
}
resource "vault_approle_auth_backend_role" "reader" {
for_each = local.approle_auth_roles
provider = vault.admin
backend = var.infra.approle_auth.path
role_name = each.key
role_id = each.key //Rather than use a GUID, we set the ID to be human-readable
bind_secret_id = each.value.bind_secret_id
token_bound_cidrs = can(each.value.bound_cidrs) ? each.value.bound_cidrs : null
secret_id_bound_cidrs = can(each.value.bound_cidrs) ? each.value.bound_cidrs : null
}
In the refactor, this is now in a tfvars (no change in content or code otherwise), and the behavior is different and it fails.
Terraform will perform the following actions:
# module.standard_customers.vault_approle_auth_backend_role.reader["test_app_dev"] will be updated in-place
~ resource "vault_approle_auth_backend_role" "reader" {
id = "auth/approle_auth/role/test_app_dev"
~ secret_id_bound_cidrs = [
+ null,
]
~ token_bound_cidrs = [
+ null,
]
# (15 unchanged attributes hidden)
}
# module.standard_customers.vault_approle_auth_backend_role.reader["test_app_prod"] will be updated in-place
~ resource "vault_approle_auth_backend_role" "reader" {
id = "auth/approle_auth/role/test_app_prod"
~ secret_id_bound_cidrs = [
+ null,
]
~ token_bound_cidrs = [
+ null,
]
# (15 unchanged attributes hidden)
}
ā·
ā Error: error updating AppRole auth backend role "auth/approle_auth/role/test_app_dev": Error making API request.
ā
ā Namespace: admin
ā URL: PUT https://company-hcp-sre-dev-private-vault-dff8581e.86e0ac9c.z1.hashicorp.cloud:8200/v1/auth/approle_auth/role/test_app_dev
ā Code: 400. Errors:
ā
ā * error parsing address "": Unable to convert "" to an IPv4 or IPv6 address, or a UNIX Socket
ā
ā with module.standard_customers.vault_approle_auth_backend_role.reader["test_app_dev"],
ā on ..\..\..\..\modules\customers\standard\approle_auth_entities.tf line 14, in resource "vault_approle_auth_backend_role" "reader":
ā 14: resource "vault_approle_auth_backend_role" "reader" {
ā
āµ
ā·
ā Error: error updating AppRole auth backend role "auth/approle_auth/role/test_app_prod": Error making API request.
ā
ā Namespace: admin
ā URL: PUT https://company-hcp-sre-dev-private-vault-dff8581e.86e0ac9c.z1.hashicorp.cloud:8200/v1/auth/approle_auth/role/test_app_prod
ā Code: 400. Errors:
ā
ā * error parsing address "": Unable to convert "" to an IPv4 or IPv6 address, or a UNIX Socket
ā
ā with module.standard_customers.vault_approle_auth_backend_role.reader["test_app_prod"],
ā on ..\..\..\..\modules\customers\standard\approle_auth_entities.tf line 14, in resource "vault_approle_auth_backend_role" "reader":
ā 14: resource "vault_approle_auth_backend_role" "reader" {
ā