Hi, I have a problem where I need data of the out...
# typescript
Hi, I have a problem where I need data of the output of a stack reference to determine whether I should import a resource in my Pulumi program. Since
of a Pulumi resource does not accept output values I need to resolve this value before running the pulumi program, but when I try to resolve the promise of`getOutputValue`of a
I get the following error message (since the output on the stack reference is a secret)
Cannot call 'getOutputValue' if the referenced stack output is a secret. Use 'getOutput' instead.
Are there any ways around this issue? I would like to be able to preview the changes to my resource, so I can't put the creation of the resource into the apply callback.
Generally, importing is a once-off process, so you don't (usually) write code for it. Either you use
pulumi import
to put the resource in your state, or you use the import opt in your code for a single run or
pulumi up
, then remove it. Is this the case for your use-case? If it is, you shouldn't need to call getOutput or getOutputValue. Just use
pulumi stack output
to get the value on the console, and write your import code using that.
Unfortunately not in this case. We're writing a self-service portal, and we have a use case where a resource being created sometimes have been created manually by some teams beforehand, so we're trying to account for that. In this case an ID for the resource we're importing can be found in a referenced stack, but I'm just not able to retrieve it beforehand since it's in a secret output.
Then you'll have to use
. This won't affect the creation of the resource if you're not using this value for the name: outputs can be passed into the constructor's args parameter. Just don't use this value in the name parameter.
Or you could reproduce the code that exports this value. Since the only time it can be important is if the resource is unmanaged, you won't be double-managing the resource: both stacks will have read-only handles on the resource. So it's safe to use the get-code in the current stack.