Config with `1.0` and `1.1` seems pretty broken du...
# general
q
Config with
1.0
and
1.1
seems pretty broken due to change in the stack naming: https://github.com/pulumi/pulumi/issues/3223
b
thanks for heads up
q
I guess there's no way for me to unblock myself atm?
b
try editing stack config file directly
so instead of using
pulumi config set
, just edit yaml file
q
I already tried that, the config can't be unmarshalled
b
how does error look like?
q
Copy code
╰ pulumi preview
error: getting secrets manager: could not unmarshal map: could not parse devrel-metrics:telegraf:version as a configuration key (configuration keys should be of the form `<namespace>:<name>`)
b
are you sure there is no typo in
devrel-metrics
(letter 'r') ?
q
Positive
My team is developer relations
devrel
b
ah, variable names probably can't have
:
, try
telegraf_version
q
So the namespace is the project name? Isn't that rather redundant
b
there are other namespaces, each provider has one. I think it was the easiest option for them to go this route
q
but I can't specify my own namespace when using
require
or
requireSecret
?
b
I think you can: new pulumi.Config("telegraf").require("version")
q
@best-xylophone-83824 Perhaps you can help me with one final thing, if you don't mind. When I use
const password = requireSecret('name');
I get an
Output
. This means I can't render a file to put in my
startupScript
. What is the expected way to handle this?
c
If you do not specify a namespace when you do
pulumi.config()
it uses the project name. If you do specify it, then the variable has to have the namespace name like
namespace:key
To my knowledge this is how it has always worked
q
Thanks @cool-egg-852
any idea on the secret Output too? 🙂
c
You need to either use
.apply
or
pulumi.interopolate
or a string template in some cases. It all depends on the situtation and also the style you want to go with.
b
@quiet-wolf-18467
Copy code
const startupScript = password.apply(pw => `myScript with password=${pw}`);
q
I'm trying to use
handlebars
handlebars doesn't know how to deal with the pulumi object, as it has no
toHTML
method
I feel like I'm fighting an uphill battle with this one
c
I’m sure it’s possible. You might want to post your code here so we can take a look and see.
c
And what’s the part that isn’t working right?
q
Line 40
Copy code
Diagnostics:
  pulumi:pulumi:Stack (devrel-metrics-production):
    error: Running program '/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/src/index.ts' failed with an unhandled exception:
    TypeError: string.toHTML is not a function
        at escapeExpression (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/utils.js:68:21)
        at Object.eval (eval at createFunctionContext (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/
compiler/javascript-compiler.js:239:23), <anonymous>:12:7)
        at main (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/runtime.js:152:32)
        at Object.ret (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/runtime.js:155:12)
        at Object.ret [as output-influxcloud] (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/compiler
/compiler.js:513:21)
        at Object.invokePartialWrapper [as invokePartial] (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handleb
ars/runtime.js:51:46)
        at Object.eval (eval at createFunctionContext (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/
compiler/javascript-compiler.js:239:23), <anonymous>:8:28)
        at main (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/runtime.js:152:32)
        at ret (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/runtime.js:155:12)
        at ret (/home/rawkode/Code/src/github.com/influxdata/devrel-metric-collection/node_modules/handlebars/lib/handlebars/compiler/compiler.js:513:21)
handlebars is trying to use the
Output
object from Pulumi and can't render it to a string
b
try
Copy code
const data = pulumi.output({
  telegrafVersion: config.require("telegraf_version"),
  influxCloudUrl: config.require("influxcloud_url"),
  influxCloudUsername: config.require("influxcloud_username"),
  influxCloudPassword: config.requireSecret("influxcloud_password"),
  influxCloudDatabase: config.require("influxcloud_database"),
  influxCloud2Url: config.require("influxcloud2_url"),
  influxCloud2Bucket: config.require("influxcloud2_bucket"),
  influxCloud2Organization: config.require("influxcloud2_organization"),
  influxCloud2Token: config.requireSecret("influxcloud2_token")
});

...

metadataStartupScript: data.apply( cfg => startupScriptCompiledTemplate(cfg)),
did it work?
q
Just walking my dog round the block. Let you know in 10 😀
@best-xylophone-83824 Looking good 🙂
Thank you so much for your help
c
cc @microscopic-florist-22719?