Hi, I have a few `pulumi,export` statements in st...
# getting-started
s
Hi, I have a few
pulumi,export
statements in stack A. Now, I have
pulumi.StackReference
in stack B to reference the export statements of stack A. Is it possible?
s
Yes! That's exactly what
StackReference
is for!
s
I’m using Python and am not able to get to the point that I get those exports…
Copy code
streams_stack = pulumi.StackReference(
    config.require("stack-A")
)
print(streams_stack.outputs.__dict__.__getitem__("arn"))
tried all kinds of options but no luck
s
Like this:
Copy code
config = pulumi.Config()
stack = pulumi.get_stack()
org = config.require("org")
stack_ref = pulumi.StackReference(
    f"{org}/aws-cloudwan-workshop-cloudwan/{stack}")

core_network_id = stack_ref.get_output("core_network_id")
s
I’ve tried that but no luck… this is what I have in stack A:
Copy code
pulumi.export('stream_a',
              {"arn": stream_a.arn, "name": stream_a.name, "alias": data_kinesis_kms_alias.name})
I’m trying to do `get_output(“stream_a)
seeing this message:
Copy code
Calling __str__ on an Output[T] is not supported.
    To get the value of an Output[T] as an Output[str] consider:
    1. o.apply(lambda v: f"prefix{v}suffix")
    See <https://pulumi.io/help/outputs> for more details.
    This function may throw in a future version of Pulumi.
could be because I’m doing
pulumi preview
?
same issue with pulumi up
Ahh, I was trying to add the Output[T] inside a string policy… so had to use
apply
and place the whole policy inside the lambda…
s
Ah yes. Policies are the most common use case for apply. Glad you got unstuck!