Question for the collective Pulumi brain about `St...
# general
f
Question for the collective Pulumi brain about
StackReference
outputs. I've got one project that sets up all our Github repositories, and another project that sets up our CI/CD pipelines for those repositories. Based on whether the repository in question is public or private, I will tweak how the pipelines are set up. I think "no problem, that's what
StackReferences
are for!" So I'm exporting the visibility of each of my repositories as an output from my Github project for consumption by my CI/CD project. However, anything I get from a
StackReference
is an
Output
, which is fine if I only needed to pass that output directly to a new
Resource
as an input. Unfortunately, I need to perform some extra-
Resource
logic based on the value of this
Output
("do I pass this pipeline definition to the Resource, or that pipeline definition?").
Output.apply
doesn't do the trick because this is happening in the initial "compilation"/pre-processing stage of the Pulumi run, rather than the "execution"/actual-creation-of-Resources stage. Is there some trick I'm missing in this situation? Alternatively, is there some other way of structuring things that would make this more straightforward? (I'm using the Python SDK, FWIW.) Thanks in advance.
b
apply should work here, what error are you getting?
f
Hrmm... I just modified my apply call and it looks like it's working. 🤔
Initially, I was just trying to use an identity function (
thing.apply(lambda x: x)
) and then doing a comparison based on the result, which wasn't working. If I pull that comparison into the apply (
thing.apply(lambda x: x == "blah")
), it works
well, maybe not... I still can't log the output of the transformed thing with
pulumi.log
(I just get something like
<pulumi.output.Output object at 0x78b40441e0b8>
, and it doesn't look like it's actually behaving as a boolean in my code.
wonder if I need to pull my "do I pass this pipeline definition to the Resource, or that pipeline definition?" logic into the apply call as well...
because that is what is ultimately passed as a Resource input