Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Create KV2 secret fails if the KV2 mount parent is just created #2322

Open
radup123 opened this issue Sep 11, 2024 · 1 comment
Open
Labels

Comments

@radup123
Copy link

Terraform Core Version

1.3.3

Terraform Vault Provider Version

4.4.0

Vault Server Version

1.16.5

Affected Resource(s)

No response

Expected Behavior

Create KV2 secret works even if the KV2 mount parent is just created.

Actual Behavior

The kv2 mount is created but when creating the secret I get this error:
│ * no handler for route "kv2_mount/data/secret/my-secret". route entry not found.

If I reapply, it the secret gets created.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

main.tf.zip

Steps to Reproduce

Issue is not always reproducible.

  1. Create KV2 mount point
  2. Create secret under the mount created at step 1.
  3. Observe error : │ * no handler for route "kv2_mount/data/secret/my-secret". route entry not found.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@radup123 radup123 added the bug label Sep 11, 2024
@fairclothjm
Copy link
Contributor

fairclothjm commented Sep 19, 2024

Hello @radup123! I am sorry you are having trouble!

Thanks for providing the TF config. I took a look and the issue is that TF does not understand the dependency relationship between the two resources. In particular, vault_kv_secret_v2 needs to make a reference to the vault_mount's named value because the backend must be mounted before we can create the secret.

So change the vault_kv_secret_v2 resource to this

 resource "vault_kv_secret_v2" "secret" {
   name = "secret/my-secret"
-  mount = "kv2_mount"
+  mount = vault_mount.kv2_mount.path
   data_json = jsonencode(
   {
     "key" = "value",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants