Hi folks. The following is designed to iterate ov...
# general
m
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
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
what is the suggested pattern here?
b
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
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
well that’s certainly not expected, can you file an issue with a repro?
m
let me know if that needs more clarity
simple way to repro in there
b
thankyou, the team will triage