sparse-intern-71089
07/24/2019, 7:12 PMbroad-football-5123
07/24/2019, 7:16 PM.get()
or does that throw an error?modern-bear-85657
07/24/2019, 7:29 PM.get()
errors in preview and instructs to use .apply()
instead. It’s a hassle. I saw a thread yesterday where they’re trying to address this, though.white-balloon-205
early-musician-41645
07/24/2019, 8:06 PMpulumi.Output<string>
?early-musician-41645
07/24/2019, 8:07 PMconsole.log
the output, but I can not do something like:
let myString: string = myPulumiOutput.apply(val => return val);
early-musician-41645
07/24/2019, 8:09 PMearly-musician-41645
07/24/2019, 8:13 PMstring
, hence I'm doing a JSON.stringify
on the secretString:
83 let secretString = {
84 publicKey: publicKey,
85 privateKey: privateKey
86 };
96 const secretVersion = new aws.secretsmanager.SecretVersion("v1", {
97 secretId: secret.id,
98 secretString: JSON.stringify(secretString),
99 });
I don't see other examples around this that allow me to shove a pulumi.Output<string>
as above into the secretString directly. Am I missing some step or info?
@white-balloon-205?white-balloon-205
Is there a definitive way to get a string from aIt is not possible to turn an?pulumi.Output<string>
Output<string>
into a string
because an Output<string>
represents a value that may or may not be known.
The primary way to see the value inside is to use .apply(v => ...)
and write whatever logic you want to happen if/when the value is available inside that callback.white-balloon-205
white-balloon-205
I believe the secretString for secrets requires aNo - it expects anstring
Input<string>
, which can be either a string
or an Output<string>
.white-balloon-205
early-musician-41645
07/24/2019, 8:18 PMearly-musician-41645
07/24/2019, 9:09 PMpulumi.Output
things are working... sort of.
Last hurdle is this:
44 let secretString = pulumi.output(`{"publicKey":"${publicKey}", "privateKey":"${privateKey}"}`);
45
46 const secret = new aws.secretsmanager.Secret(secretName, {
47 name: secretName,
48 description: "SSH keypair for worker nodes in an EKS cluster",
49 });
50
51 const secretVersion = new aws.secretsmanager.SecretVersion("v1", {
52 secretId: secret.id,
53 secretString: secretString,
54 });
The secret is created, however, the actual value of the secretString is:
{"publicKey":"Calling [toString] on an [Output<T>] is not supported.
To get the value of an Output<T> as an Output<string> consider either:
1: o.apply(v => `prefix${v}suffix`)
2: pulumi.interpolate `prefix${v}suffix`
See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of @pulumi/pulumi.", "privateKey":"Calling [toString] on an [Output<T>] is not supported.
To get the value of an Output<T> as an Output<string> consider either:
1: o.apply(v => `prefix${v}suffix`)
2: pulumi.interpolate `prefix${v}suffix`
See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of @pulumi/pulumi."}
I'm trying to form a secretString
out of `pulumi.Output`s formatted into json and it's not working. How can I create a string
or Output<string>
from a combination of `string`s and `Output<string>`s for use in the secretString
?early-musician-41645
07/24/2019, 9:09 PMpublicKey
and privateKey
are both Output<string>
early-musician-41645
07/24/2019, 9:10 PMpulumi.all
??early-musician-41645
07/24/2019, 9:11 PMearly-musician-41645
07/24/2019, 9:21 PM42 // Create an AWS secret resource
43 function createSecret(publicKey: pulumi.Output<string>, privateKey: pulumi.Output<string>) {
44 let secretString = pulumi.all([publicKey, privateKey]).apply(([pub, priv]) => { return JSON.stringify({ publicKey: pub, privateKey: priv }) });
45
46 const secret = new aws.secretsmanager.Secret(secretName, {
47 name: secretName,
48 description: "SSH keypair for worker nodes in an EKS cluster",
49 });
50
51 secretString.apply(s => {
52 const secretVersion = new aws.secretsmanager.SecretVersion("v1", {
53 secretId: secret.id,
54 secretString: secretString,
55 });
56 });
57 }
early-musician-41645
07/24/2019, 9:21 PMwhite-balloon-205