Search code examples
pulumi

Pulumi: how to create an ApplicationPassword and let Azure set the value


I'd like to be able to do the following:

Is this possible?

The reason I'd like to not specify the secret value, is that I then need to commit the secret value to code, which I don't want.

The only workaround I can think of is generating the secret value in code, storing it in keyvault, retrieving it from keyvault and using that to create the ApplicationPassword, but then that would cause Pulumi to create a new secret in the keyvault (and then a new ApplicationPassword) each time I deploy the stack.


Solution

  • You can use the RandomPassword resource to generate a password that is stable between multiple runs of the same stack. It's generated once and then stored in the state file.

    const password = new random.RandomPassword("password", {
        length: 16,
        special: true,
    });
    
    // use password.result somewhere