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

sparse-state-34229

10/27/2021, 11:29 PM
raises
Copy code
TypeError: endswith first arg must be str or a tuple of str, not Output
w

witty-candle-66007

10/27/2021, 11:49 PM
Basically, you need to use
.apply()
to resolve
name
to it’s fundamental type (i.e. string) and then use
endswith
, etc.
s

sparse-state-34229

10/27/2021, 11:51 PM
thanks, i’m familiar with it but don’t see how that will work with a generator
fwiw my Pulumi repo has >4k LOC, I use outputs 😉
if it helps, this is the actual code:
Copy code
for idx, name in enumerate(
            [self.domain_name] + self.subject_alternative_names
        ):
            zone = next(filter(lambda z: name.endswith(z["name"]), self.route53_zones))
            options = self.resource.domain_validation_options[idx]
            validation_records.append(
                Record.factory(
                    resource_name=f"{name}-validation",
                    stack_name=self.component.stack_name,
                    dns_name=options.resource_record_name,
                    zone_id=zone["id"],
                    type=options.resource_record_type,
                    records=[options.resource_record_value],
                    ttl=60,
                    allow_overwrite=True,
                    tags=self.tags,
                    opts=ResourceOptions(parent=self.component),
                ).fqdn
            )
w

witty-candle-66007

10/27/2021, 11:56 PM
so I would think you could do something like:
Copy code
zone = self.route53_zones.apply(lambda zones => next(filter(lambda z: name.endswith(z["name"]), zones))
s

sparse-state-34229

10/27/2021, 11:59 PM
hmmm i’ll see if that works, thanks!