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
Importing a namespaced LDAP auth method should set the namespace attribute for the resource.
Provided a matching resource configuration, post-import terraform apply commands should indicate no changes are to be applied, and should definitely not force-recreate the LDAP auth method.
Actual Behavior
Namespaced LDAP auth methods are imported without a namespace attribute, so subsequent terraform apply commands force-recreate the LDAP auth method as changing the namespace attribute requires recreation of the resource.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
terraform {
required_providers {
vault={
source ="hashicorp/vault"
version ="~>4.2.0"
}
}
}
provider"vault" {
# namespace = ... # could be set via VAULT_NAMESPACE
}
resource"vault_namespace""namespace" {
path="testing"
}
resource"vault_ldap_auth_backend""ldap" {
namespace=resource.vault_namespace.namespace.pathpath="ldap"url="ldap://127.0.0.1"insecure_tls=truestarttls=falsebinddn="..."bindpass="..."userdn="..."userattr="..."groupattr="..."groupdn="..."groupfilter="..."
}
Note in the plan that Terraform will try to recreate the LDAP auth method because the namespace attribute has changed:
# vault_ldap_auth_backend.ldap must be replaced
-/+ resource "vault_ldap_auth_backend""ldap" {
~ accessor = "auth_ldap_xxxxxxxx" -> (known after apply)
+ bindpass = (sensitive value)
~ case_sensitive_names = false -> (known after apply)
+ certificate = (known after apply)
+ client_tls_cert = (known after apply)
+ client_tls_key = (sensitive value)
~ deny_null_bind = true -> (known after apply)
+ description = (known after apply)
~ discoverdn = false -> (known after apply)
~ id = "ldap" -> (known after apply)
+ namespace = "testing"# forces replacement
+ upndomain = (known after apply)
~ use_token_groups = false -> (known after apply)
+ userfilter = (known after apply)
~ username_as_alias = false -> (known after apply)
# (24 unchanged attributes hidden)
}
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
When namespace support was introduced in #1479 it doesn't seem like any of the import machinery was re-evaluated. The implementation for vault_ldap_auth_backend relies on schema.ImportStatePassthroughContext:
This should be used only in the case that an ID-only refresh is possible.
Since LDAP auth methods (actually, any auth method) is unaware of its containing namespace, I don't believe ID-only refreshes are possible for namespaced auth methods.
This is the same issue raised in #2030, so I believe all auth methods are likewise impacted.
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered:
I think I was expecting to use the VAULT_NAMESPACE environment variable instead of an additional var to configure the namespace property during import.
Important to note that the docs say
The import namespace will always be made relative to the namespace of the provider{} block.
but it's not just the provider block; if both VAULT_NAMESPACE and TERRAFORM_VAULT_NAMESPACE_IMPORT are set, TERRAFORM_VAULT_NAMESPACE_IMPORT will be relative to VAULT_NAMESPACE (which I think should be expected, but it's not specifically stipulated).
Terraform Core Version
1.9.5
Terraform Vault Provider Version
4.2.0
Vault Server Version
1.16.6+ent
Affected Resource(s)
Expected Behavior
Importing a namespaced LDAP auth method should set the
namespace
attribute for the resource.Provided a matching resource configuration, post-import
terraform apply
commands should indicate no changes are to be applied, and should definitely not force-recreate the LDAP auth method.Actual Behavior
Namespaced LDAP auth methods are imported without a
namespace
attribute, so subsequentterraform apply
commands force-recreate the LDAP auth method as changing thenamespace
attribute requires recreation of the resource.Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
terraform init
terraform apply
terraform state rm 'vault_ldap_auth_backend.ldap'
terraform import 'vault_ldap_auth_backend.ldap' 'ldap'
terraform plan
namespace
attribute has changed:Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
When namespace support was introduced in #1479 it doesn't seem like any of the import machinery was re-evaluated. The implementation for
vault_ldap_auth_backend
relies onschema.ImportStatePassthroughContext
:terraform-provider-vault/vault/resource_ldap_auth_backend.go
Lines 214 to 216 in 9af82cb
where the doc comment says
Since LDAP auth methods (actually, any auth method) is unaware of its containing namespace, I don't believe ID-only refreshes are possible for namespaced auth methods.
This is the same issue raised in #2030, so I believe all auth methods are likewise impacted.
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: