raises ``` TypeError: endswith first arg must b...
# python
s
raises
Copy code
TypeError: endswith first arg must be str or a tuple of str, not Output
w
Basically, you need to use
.apply()
to resolve
name
to it’s fundamental type (i.e. string) and then use
endswith
, etc.
s
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
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
hmmm i’ll see if that works, thanks!