-
Notifications
You must be signed in to change notification settings - Fork 549
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
Vault provider lookup-self on 127.0.0.1 instead of provided vault address in plan phase #829
Comments
I have found that if you want to provision Vault and configure it in the same Terraform file/directory it does not handle the dependencies properly as @t3hami described. I would like to use modules which provision servers and modules which configure Vault after those servers are ready, but this provider doesn't seem to respect module dependency. I am using Terraform 13 and module dependencies as described here: |
I'm seeing the same thing if I run an import and pass a hard-coded variable for the address into my submodule so I don't think this is a dependency issue
What it is using is the VAULT_ADDR environment variable if that's set. |
Same problem here. I looked at the code but I could not figure out exactly what happens. The thing I'm wondering is how when the provider initialization is supposed to be done. The pattern of configuring a provider with outputs of a resource clearly work for some providers (an example with the Kubernetes provider here), but it clearly does not work with the Vault provider (even with proper dependencies set to every vault resources). Maybe some advices from a Terraform ninja could be welcome here. /cc @apparentlymart |
I have a minimal working example to reproduce this : https://gist.github.com/mcanevet/f698b53a32ac28a03b729c40d9d07b9f |
I think this "feature" is not officially supported yet (hashicorp/terraform#4149), but somehow works for some providers. |
I think the root cause here is that the current Terraform SDK (which has no real name of its own, but we often call it A way that other providers manage to avoid this situation is by deferring their connection until later on, when they are ready to perform an operation. For example, the The I'm not familiar enough with the SDK implementation details to know if there's some way for the As @mcanevet noted, hashicorp/terraform#4149 is one way this might be addressed in the long run, by deferring certain operations entirely until a first round of changes have been applied. There is no plan to implement that in the short term because it's a significant change to Terraform's typical workflow (it might be necessary to run As I proposed it, hashicorp/terraform#4149 is basically the same as running Terraform with the Splitting the configuration into two parts that can be applied separately in sequence is the most robust, repeatable answer with today's Terraform. |
For those who are running into this, there is a workaround. Be aware of the potential security implications when using this workaround: It seems the vault provider wants to do a token capabilities lookup, probably to check if it can create child tokens, but this happens regardless of resource dependencies. It will do this lookup out of order and can end up using empty/default values (address/token). I know providers having dependencies isn't really something Terraform fully supports at the moment. The Consul/Nomad providers don't have the same issue and do work well already with Terraform's existing resource dependencies. |
works with opentofu 😇 |
Hi there,
I'm using Terraform to create GKE cluster, deploy vault helm charts in the cluster, initialise vault and then create policies, auth, secrets etc. I'm passing vault address (data.kubernetes_service.vault.load_balancer_ingress.0.ip) to vault provider which is coming from kubernetes service data source. The problem is when I use
terraform plan
, terraform hits some local URL https://127.0.0.1:8200/v1/auth/token/lookup-self instead of going to the URL which will be fed by the kubernetes service data source (The thing is terraform can't use this as the GKE isn't deployed and the kubernetes service data depends on that). When I set VAULT_ADDR to my local vault, it passes the error and then I use terraform apply which also works fine. The terraform documentation says that it automatically handles the depends_on graph when you use data from one resource to another, as it knows what to create first. I need a way to ignore vault lookup-self at the time of terraform plan.Vault provider
Note: I'm using depends_on = [null_resource.vault_init] in all vault resources.
The text was updated successfully, but these errors were encountered: