https://pulumi.com logo
#general
Title
# general
m

many-pencil-40333

08/08/2023, 8:16 PM
Hi folks. The following is designed to iterate over a list of nameservers returned by a resource. for whatever reason there is no output and the cloudflare records are not created. i read that it's not a great idea to create resources in a callback. can you help me understand why this does not work? Thanks!
Copy code
self.cloudflare_ns_records = self.gcp_zone.name_servers.apply(
            lambda nss: map(
                lambda ns: cloudflare.Record("%s-nameserver-record-%s" % (pulumi.get_stack(), ns),
                    zone_id=self.cloudflare_zone.id,
                    name=pulumi.get_stack(),
                    type="NS",
                    value=ns,
                    opts=pulumi.ResourceOptions(parent=self)),
            nss))
b

billowy-army-68599

08/08/2023, 8:17 PM
it’s hard to debug without a full working example, but the likely reason is that the outputs never resolve so the underlying records never actually get created
m

many-pencil-40333

08/08/2023, 8:19 PM
what is the suggested pattern here?
b

billowy-army-68599

08/08/2023, 8:21 PM
there are circumstances like this where there isn’t really an alternative, but to debug this you’ll likely need to export
self.gcp_zone.name_servers
and verify it’s actually populated with values
m

many-pencil-40333

08/08/2023, 8:21 PM
it is. i see them
oh very strange. if i do an export on the mapped resources it creates them properly.
pulumi.export("foo", self.cloudflare_ns_records)
and if i delete that line it wants to remove the records
b

billowy-army-68599

08/08/2023, 9:01 PM
well that’s certainly not expected, can you file an issue with a repro?
m

many-pencil-40333

08/09/2023, 3:19 PM
let me know if that needs more clarity
simple way to repro in there
b

billowy-army-68599

08/09/2023, 3:21 PM
thankyou, the team will triage
2 Views