https://pulumi.com logo
#python
Title
# python
f

fast-whale-9064

04/18/2019, 5:49 PM
I’m trying to properly order route53 record creation using
.apply
but it doesn’t work like I would expect:
Copy code
record = route53.Record(dns_name,
                        name=dns_name,
                        records=[new_instance.private_ip],
                        ttl=60,
                        type="A",
                        zone_id="..."")

dns_name = record.name.apply(lambda n: n)
yields
dns_name
value of
<pulumi.output.Output object at 0x110e60160>
. What am I missing?
i

incalculable-sundown-82514

04/18/2019, 5:51 PM
apply
transforms an Output into another Output by running a function on the value within that Output.
lambda n: n
is the identity function, so what you get is
record.name
, which is an output. You can’t operate directly with outputs, but you can use
apply
to transform them and you can pass them directly to other resources: https://pulumi.io/reference/programming-model.html#outputs
f

fast-whale-9064

04/18/2019, 5:58 PM
The example under https://pulumi.io/reference/programming-model.html#apply implies that what I’m doing would work, right? It’s constructing a string from some output. I would like to understand this further, but perhaps there is a better way to indicate a dependency ordering to Pulumi. In this case the dependency is implicit, only magic strings relate these resources.
i

incalculable-sundown-82514

04/18/2019, 5:59 PM
Yes, but what you linked is not the same as what you’re doing, right?
record.name.apply(lambda n: n)
is a no-op transformation on
record.name
, whereas the thing you linked transforms an output by putting
https://
on the front of it.
What you get back in both cases is an
Output
, but one that has been transformed according to your function
f

fast-whale-9064

04/18/2019, 6:03 PM
If I’m understanding, there is no way for me to get a value out of an Output outside of being part of an Input
i

incalculable-sundown-82514

04/18/2019, 6:03 PM
That’s correct - that’s part of the design. Do you need the value?
or, more specifically, what do you need the value for?
f

fast-whale-9064

04/18/2019, 6:04 PM
I don’t. Ultimately I need my two dns records created in the proper order. One is a real record and the other is an alias to the first record. There is no hard dependency, and Pulumi is trying to create them out of order and failing on the alias.
My attempt with
apply
was to force a dependency
i

incalculable-sundown-82514

04/18/2019, 6:06 PM
If you want to force a dependency, you can use `depends_on`: https://pulumi.io/reference/pkg/python/pulumi/index.html#pulumi.ResourceOptions
Though if there is a required ordering between these two resources, that seems to me like it is a dependency
f

fast-whale-9064

04/18/2019, 6:22 PM
It is a dependency within aws, but the Output of one is not an Input to the second within my script.
I got
depends_on
to work for me, though. Thanks @incalculable-sundown-82514!
i

incalculable-sundown-82514

04/18/2019, 6:23 PM
great, no problem!