faint-tiger-16075
11/15/2021, 8:54 PMpulumi config set --secret [name] [value]
, but when I attempt to do cfg.requireSecret('[name]')
I'm getting an error during pulumi up
(see screenshot). If I hard code my variable (rather than using config) it works....I've tried the suggestions in the error, I've set the config variable to plaintext
and used cfg.require('[name]')
and still doesn't work....I've studied the secrets documentation....am I missing something?${x}
);quick-lifeguard-72252
11/15/2021, 9:03 PMapply()
closure. Like this:
cfg.requireSecret("repositoryToken").apply(x => useToken(x));
apply
returns an Output
so you can't use it directly.
Although all the Pulumi docs tell you to use apply
. I actually found it a lot easier to only use Promise with async/await. You can convert an Output
to a Promise with this:
const fut = new Promise(f => output.apply(f));
await
on it yourself.billowy-army-68599
11/15/2021, 9:18 PMfaint-tiger-16075
11/15/2021, 11:02 PMimport * as pulumi from "@pulumi/pulumi";
import * as resources from "@pulumi/azure-native/resources";
import * as applatform from "@pulumi/azure-native/appplatform";
import * as azureweb from "@pulumi/azure-native/web";
const cfg = new pulumi.Config();
const repositoryToken = cfg.requireSecret('repositoryToken');
const frontend = new azureweb.StaticSite("static-site-name", {
resourceGroupName: "[resourceGroupName]",
branch: "main",
name: "static-site-name",
sku: {
name: "Free",
tier: "Free"
},
repositoryUrl: "[repositoryUrl]",
repositoryToken: repositoryToken
});
requireSecret
call so I'm a bit confused.quick-lifeguard-72252
11/16/2021, 12:57 AMapply
and async/await accomplish the same thing. But with async/await you don't get callback hell.const repositoryToken =
await new Promise(f => cfg.requireSecret('repositoryToken').apply(f)) as string;
And keep rest of the code the same.
But with apply:
cfg.requireSecret('repositoryToken').apply(repositoryToken => {
const frontend = new azureweb.StaticSite("static-site-name", {
resourceGroupName: "[resourceGroupName]",
branch: "main",
name: "static-site-name",
sku: {
name: "Free",
tier: "Free"
},
repositoryUrl: "[repositoryUrl]",
repositoryToken: repositoryToken
});
})
The nesting can get annoying pretty quickly unless there's a trick I don't know about.