https://pulumi.com logo
#general
Title
# general
b

blue-judge-71382

06/07/2022, 9:58 AM
Anyone knows how to unsecret values of stack.outputs()? It seems pulumi.unsecret is used for config values. Thanks:)
🆘 1
👀 1
I didn't find any information on the Pulumi doc or google.
Could anyone give an example?
q

quaint-eye-38036

06/07/2022, 10:01 AM
pulumi stack output --show-secrets
❤️ 1
p

prehistoric-activity-61023

06/07/2022, 10:44 AM
if you want to show values that are secrets, use
--show-secrets
as @quaint-eye-38036 wrote
if you want to convert some output that’s a secret to a plain value… I’ll have to think 🤔
I’m checking if that works:
Copy code
# standard secret
pulumi.export("sql_root_password", sql.root_user.password)

# my attempt
pulumi.export("sql_root_password_plain", pulumi.Output.unsecret(sql.root_user.password))
I think it works just fine. The above snippet is for python so if you’re using some other lang, you should be able to find a counterpart function. Anyway,
unsecret
seems like a way to go 🙂.
Saying that… I’m not sure it’s a good idea to unsecret secrets 😐. I’d think twice before doing it. If you want to check the secret values, you should leave them as they are but use
--show-secrets
. Within the code, you shouldn’t really need to unsecret them (just use them directly).
❤️ 1
b

blue-judge-71382

06/08/2022, 3:26 AM
Thank you guys! I am developing a web application for internal team to manage all the aws cloud resources including IAM, CodeCommit etc. When I create a IAM user with Git credentials, I need to know the plaintext git password to use. Do you have the same situation?
async getStackOutputs(
projectName: string, stackName: string, stackType: InfrastructureStackType ) { // [step 1] Create stack args. const args: InlineProgramArgs = { projectName, stackName, program: async () => {}, }; // [step 2] Get stack. const stack = await LocalWorkspace.selectStack(args); await stack.workspace.installPlugin(‘aws’, this.pulumiAwsVersion); await stack.setAllConfig({ ‘awsregion’ {value: this.awsRegion}, ‘awsprofile’ {value: projectName}, }); // [step 3] Get stack outputs. const outputs = await stack.outputs(); const outputKeys = this.getStackServiceByType(stackType)?.getStackOutputKeys(); return outputKeys?.map(key => { if (outputs[key].secret) { return {[key]: pulumi.unsecret(outputs[key].value)}; } else { return {[key]: outputs[key].value}; } }); }
2 Views