rhythmic-magazine-46691
04/11/2024, 6:04 PMI'm trying to use stackreferences. project1 : the stack output is a json object projectInfo = { "key1": "value1", "key2" : "value2" }. project2: read the stack reference from project1, and then use the value of "key1" in the project2.
I've tried various approaches, including the once suggested by Pulumi AI, but all i get is Pulumi output, rather than the object.
https://www.pulumi.com/ai/conversations/540df593-e144-4994-a274-ac71664e54ab
Stackoutput from project 1:
projectInfo = {
"key1" : "value1",
"key2" : "value2"
}
In project 2:
The expectation is
const projectInfo = new pulumi.StackReference("<org>/<project>/<stack name>");
I've tried various permutations:
const output = stackRef.getOutput("projectInfo)
const output = stackRef.getOutput("projectInfo).apply(t => t.key1);
output.apply(t => console.log(t)); // this works and prints to log
const someOutput = output.apply(t => {return t});
console.log(output["key1"]
expected output: value1
actual output :
OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
glamorous-train-61849
04/16/2024, 3:20 PMimport * as pulumi from "@pulumi/pulumi";
// In project2's Pulumi program
// Create a StackReference to project1
const project1StackRef = new pulumi.StackReference("organization/project1/dev");
// Access the "key1" value from project1's exported outputs
export const shopUrl = project1StackRef.getOutput("key1");
// Now you can use key1Value in your resource definitions as needed
// For example, you might use it to set an environment variable on a cloud service
https://www.pulumi.com/learn/building-with-pulumi/stack-references/