damp-lock-9822
02/03/2023, 11:49 PMminiature-musician-31262
02/03/2023, 11:54 PMapply
as described here: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/?language=python#applydamp-lock-9822
02/04/2023, 12:00 AMminiature-musician-31262
02/04/2023, 12:59 AMapply
is an Output[T]
, but within the callback that’s passed to apply, you can work with the raw `T`:
bucket = s3.Bucket('my-bucket')
def compare(a, b):
if a == b:
print("match")
else:
print("no match")
bucket.id.apply(lambda id: compare(id, "some-string"))
bucket = s3.Bucket('my-bucket')
some_known_value = "foo"
# Capture the result as an Output[bool].
is_match = bucket.id.apply(lambda id: id == some_known_value)
# Use its apply() to work with the result.
is_match.apply(lambda m: print("Match!" if m else "No match."))
damp-lock-9822
02/06/2023, 6:33 PM