Giter Site home page Giter Site logo

Comments (5)

remilapeyre avatar remilapeyre commented on August 10, 2024 1

Hi @dantheman999301, radom_string uses crypto/rand under the hood and rand.Reader to give cryptographically secure strings and I'm not sure it will be possible to add a seed parameter.

from terraform-provider-random.

tomasaschan avatar tomasaschan commented on August 10, 2024 1

I'd like to be able to do this as well!

Basic use case:
I handle an application with multiple environments and tenants. so for each env/tenant combo, there are

  • some shared resources (the same in all env/tenants)
  • some environment resources (the same for all tenants in an environment)
  • some tenant resources (unique per tenant)
    To switch between them, I have an init script which reconfigures terraform for the target env/tenant combo, and imports any resources missing from the state.

Now, I have environment resources based on random_string, e.g. database credentials for server instances shared within the environment. I can import the database server itself OK, but because the random_string resources are different in the new env/tenant, terraform wants to destroy and recreate it with the new credentials (which will break the existing tenants in that environment). Ideally i'd like to seed the random_string resources based on the environment name, but that doesn't seem to be what keepers do (setting a keeper to the env name and reconfiguring yields different random_string results, even though the keeper value has not changed).

I could probably work around it with a random int, seeded with something derived from the environment name, then hash that int, but it would be much nicer to work with if I didn't have to.

Maybe random_string can switch to a different RNG if a seed is provided? (If the user is providing a seed, cryptographic security is probably not a concern).

from terraform-provider-random.

deadwards90 avatar deadwards90 commented on August 10, 2024

Yes, I did notice that when I was having a poke around (but I don't know Go or it's libraries that well).

I ended up somewhat hacking around it using a random id and then converting that to hex so it was uri friendly which did the job but was not that nice.

I could even create a random int (with a seed), then hash it and then strip it to X characters but it just seems a bit of a hack. But if it can't be done, it can't be done!

from terraform-provider-random.

remilapeyre avatar remilapeyre commented on August 10, 2024

@tomasaschan Is it not possible to import the random_string resource as well?

from terraform-provider-random.

tomasaschan avatar tomasaschan commented on August 10, 2024

@remilapeyre Maybe; I haven't been able to figure out how to export/import them. (The other resources I import based on their actual state in Azure, but the random_string resources naturally don't exist there, and the properties they write to in the configuration are write-only.)

from terraform-provider-random.

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.