Is there a way to reproduce the behaviour of Rando...
# general
p
Is there a way to reproduce the behaviour of Random for my own custom resources? I have a generated value that i later store in Vault but that i never want to regenerate. So how do i prevent
generateValue
to run on next runs?
Copy code
export class Example extends ComponentResource {

  constructor(name: string, opts?: ComponentResourceOptions) {
    super('example', name, {}, opts);

    const generated = somelib.generateValue();

    new Secret(
      name,
      {
        path: `somepath/${name}`,
        dataJson: 
          JSON.stringify(generated)
        
      },
      { parent: this, ignoreChanges: ['*'], protect: true }
    );
  }
}
q
You generate the random value externally and feed it via configuration into your stack.
Copy code
$ program-to-generate-value | pulumi config set generatedValue --secret
Then in your program:
Copy code
const config = new pulumi.Config();
const generated = config.requireSecret('generatedValue');
p
wanted to prevent that 😉 dynamic providers look like what i need https://www.pulumi.com/docs/intro/concepts/resources/dynamic-providers/
q
I guess it depends on the kind of value you want to generate. 😉 It could also be that instead of a random value you could apply some kind of deterministic hash function on the inputs?
e
I mean you could just use the random provider inside your component resource?
But yes dynamic providers are a good way to do this if the random provider isn't sufficient.