I’m trying to properly order route53 record creati...
# python
f
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
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
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
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
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
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
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
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
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
great, no problem!