Does StackReference only work with the Pulumi Clou...
# general
s
Does StackReference only work with the Pulumi Cloud Platform? I'm currently using Pulumi with the file based state backup, but unless I'm missing something, I can not seem to get it to work, I've read through the documentation as well, and looked for samples, but there isn't much to find. So here's my scenario, I have a project, broken down by infra and app, the infra sets up ECS and references the ECR repository url of the app that's built and pushed. So there's a stack in app and one in infra. It would look like this:
Copy code
/project/app/index.ts
/project/app/Pulumi.dev.yml
/project/infra/index.ts
/project/infra/Pulumi.dev.yml
One of the outputs from the app project is the repository url as
repositoryUrl
. I would like to access this from the infra project. This is what I tried
pulumi.StackReference("../app/dev").getOutput("repositoryUrl")
, but I realise this is not the way to do it. How would I go about doing this using the local state implementation?
b
Maybe the section on Outputs will be helpful here https://pulumi.io/reference/programming-model.html#output
s
I think my question is more, how would I go about referencing the dev stack in the app project from the dev stack in the infra project using
StackReference
so I can access one of it's outputs, whilst doing this using the local file based state management
c
cc @microscopic-florist-22719 who I think would know.
👍 1
m
You should be able to use the stack name just as you would with a cloud-backed stack.
s
I have figured out a workaround. The problem is, the local login defaults to ~ So anywhere a project is defined, there will be a local state folder for that. The workaround was to login locally using a folder that could be referenced by all projects. In other words, all projects state will exist there, like at the root of a drive for example
C:\\pulumi_state
. That way I was able to use
StackReference
with the stack name as suggested.