Giter Site home page Giter Site logo

Missing strict ordering: vault_mount must happen before vault_generic_secret (at least for PKI backend) about terraform-provider-vault HOT 6 CLOSED

hashicorp avatar hashicorp commented on August 15, 2024
Missing strict ordering: vault_mount must happen before vault_generic_secret (at least for PKI backend)

from terraform-provider-vault.

Comments (6)

therealbill avatar therealbill commented on August 15, 2024

The problem is that TF has no way to know that your second resource depends on the first. One option would be to reference the mount's path in defining the secret's path definition. For example,
path = "${vault_mount.team5_k8s_apiserver.path}/root/generate/internal"

By doing so you tell Terraform that the second resource requires the first, and they should be done serially.

Alternatively you could use depends_on to specify the relationship w/o using interpolation in the path. Personally, I'd prefer the interpolation route. Doing so allows you to change it in one location, should you want to, rather than tracking them down. Ultimately either way you're letting Terraform know that resource B needs resource A and that is the critical information it needs to make the decision.

from terraform-provider-vault.

phinze avatar phinze commented on August 15, 2024

Thanks for filing this! I just bumped into it myself. @therealbill your answer is spot-on - I'm applying the dependency-ordering-via-interpolation workaround to my config right now.

It still would be nice if Terraform could sort out these implicit dependencies between certain kinds of resources. I believe that would require a new core <-> provider API. It's definitely worth considering. I'll chat with the TF core folks about it at some point. 💭 👍

from terraform-provider-vault.

syndbg avatar syndbg commented on August 15, 2024

@andrejvanderzee @phinze https://www.terraform.io/intro/getting-started/dependencies.html#implicit-and-explicit-dependencies

from terraform-provider-vault.

phinze avatar phinze commented on August 15, 2024

Ah thanks @syndbg I had forgotten we call dependencies created via interpolation "implicit dependencies". I guess the potential feature I was referring to was more like "automatic dependencies" whereby Terraform would recognize that resources of a certain type need to always follow resources of another type given certain matching attributes. Just me musing on potential core functionality. 😄

In the meantime - using interpolation to draw "implicit dependencies" is the way to go!

from terraform-provider-vault.

syndbg avatar syndbg commented on August 15, 2024

Yep, it would be easier for use, but overall increase the complexity of the code greatly.

from terraform-provider-vault.

benashz avatar benashz commented on August 15, 2024

Terraform itself is responsible for managing the dependency graph. If one resource references an attribute of another, that resource will be created first e.g:

resource "vault_generic_secret" "team5_k8s_apiserver_ca" {
  path = "${vault_mount.team5_k8s_apiserver.path}/root/generate/internal"

  data_json = <<EOT
{
  "common_name": "xxx.io"
}
EOT
}

Closing this out as it is not a provider issue.

from terraform-provider-vault.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.