stocky-spoon-28903
11/08/2018, 10:34 PMruntime.allConfig()
early-musician-41645
11/08/2018, 10:36 PMstocky-spoon-28903
11/08/2018, 10:38 PMimport * as pulumi from "@pulumi/pulumi"
const allConfig = pulumi.runtime.allConfig();
early-musician-41645
11/08/2018, 10:42 PMallConfig
to get the list key-value pairs, or the list of keys?stocky-spoon-28903
11/08/2018, 10:43 PMallConfig
at that point would be a string dictionary, so you can do:
for (const key of allConfig) {
const value = allConfig[key];
// do something with value
}
early-musician-41645
11/08/2018, 10:47 PMstocky-spoon-28903
11/08/2018, 10:48 PMConfig
to allow for thatearly-musician-41645
11/08/2018, 10:50 PMpulumi.runtime.allConfig().forEach((value: string, key: string) => {
console.log(key + ": " + value);
});
error: Running program '/home/tsi.lan/eshamay/git/mustang/sdp-mustang-terraform/pulumi/mustang-tas-services' failed with an unhandled exception:
error: TSError: ⨯ Unable to compile TypeScript:
index.ts(23,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
white-balloon-205
Array#forEach
on it.
export declare function allConfig(): {
[key: string]: string;
};
early-musician-41645
11/08/2018, 11:02 PMfor (const key of allConfig) {
above but it failswhite-balloon-205
const allConfig = pulumi.runtime.allConfig();
Object.keys(allConfig).forEach(key => {
console.log(key + ": " + allConfig[key]);
});
const allConfig = pulumi.runtime.allConfig();
for (const key in allConfig) {
console.log(key + ": " + allConfig[key]);
}
stocky-spoon-28903
11/08/2018, 11:29 PMin
rather than of
.glamorous-printer-66548
11/09/2018, 12:47 AMObject.entries(allConfig).forEach(([key, value]) => {
console.log(`${key}: ${value}`)
})
at least that’s what It’d personally use haha.tsconfig.json
and set
{
"compilerOptions": {
"target": "es2017"
}
}
to let typescript know that Object.entries
exists.
And you should use node 8 or higher.