Hi community. I'm a typescript and pulumi newbie. ...
# typescript
Hi community. I'm a typescript and pulumi newbie. Can someone help me with this usecase.
Copy code
I'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 :
Copy code
OutputImpl {

  __pulumiOutput: true,

  resources: [Function (anonymous)],

  allResources: [Function (anonymous)],

  isKnown: Promise { <pending> },

  isSecret: Promise { <pending> },

  promise: [Function (anonymous)],

  toString: [Function (anonymous)],

  toJSON: [Function (anonymous)]

@rhythmic-magazine-46691 You can get the output like this for a value:
Copy code
import * 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