sparse-intern-71089
07/22/2020, 11:22 PMicy-jordan-58549
07/22/2020, 11:48 PMicy-jordan-58549
07/23/2020, 12:22 AMicy-jordan-58549
07/23/2020, 12:27 AM// @ts-ignore
const additionalConfig = configuration.promise().then((t) =>
xml.json2xml(t, {
spaces: 4,
indentText: true,
compact: true,
})
);
export const conf = new azure.storage.Blob(
"data.xml",
{
storageAccountName: storageAccount.name,
storageContainerName: container.name,
name: "data.xml",
type: "Block",
source: new pulumi.asset.StringAsset(additionalConfig),
},
{ dependsOn: [container, storageAccount] }
);
icy-jordan-58549
07/23/2020, 12:27 AMicy-jordan-58549
07/23/2020, 12:27 AMcalm-quill-21760
07/23/2020, 1:14 AMcalm-quill-21760
07/23/2020, 1:25 AM.apply
can sometimes get you the value you're after as well.calm-quill-21760
07/23/2020, 1:31 AMpulumi.output(secretsToStore).apply(JSON.stringify)
icy-jordan-58549
07/23/2020, 3:02 AMicy-jordan-58549
07/23/2020, 3:02 AMicy-jordan-58549
07/23/2020, 3:03 AMcolossal-beach-47527
07/23/2020, 4:02 PMOutput< >
and pulumi.apply
work. But my (perhaps incorrect) understanding is that you should really try to avoid relying on the state of a resource for the execution of your Pulumi program.
e.g. if you want to write the ec2VM.id
to a file or something. Because there isn’t a good way to reliably obtain that value.
If you are running a pulumi preview
(sometimes called a dry run), the resource is never created. So ec2VM.id
never actually has a value. (And throwing a runtime error is probably better than giving you “” or undefined, or something that looks correct but isn’t.)
The way Output< >
is used internally in the Pulumi engine is to ensure that operations are sequenced correctly. e.g. if resource B requires the id of resource A, then Pulumi will wait for the first resource to be created, then read the constructed value, etc.
Typically this “just works”, but in more advanced cases you’d need to do something like:
// Wait for resource A, B, C to be created.
// Then pass all their values to a lambda,
// return some Output< >
pulumi
.all([resA, resB, resC])
.apply( ([resAval, resBval, resCval]) => {
return ...
});
But the above code again only works when doing a pulumi up
. (When resA
, resB
, and resC
have been created and/or are “known”.)
That is my vague/hazy understanding, so as for your specifc question:
If I want to fs.writeMy (again, perhaps incorrect/incomplete/wrong) understanding is: 1. You might not want to be doing that, it might be a code smell. 2. as an FYI, getting the, how I can do that?Output<string>
Output<>
won’t work in “previews” and only “updates”.
3. “something something pulumi.all(…).apply(…)
might get you the value, but unfortunately will itself return an Output< >
. (So you’d see it as a side-effect during the Pulumi program’s execution, but never during a preview, etc.)
Hopefully that is some non-zero amount of helpful. (And maybe someone else on the team more knowledgeable can point you in a clearer direction.)icy-jordan-58549
07/23/2020, 6:58 PMicy-jordan-58549
07/23/2020, 6:59 PMicy-jordan-58549
07/23/2020, 6:59 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by