File size: 681 Bytes
e18c302 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from typing import Any
from aws_lambda_powertools.utilities.feature_flags import AppConfigStore, FeatureFlags
from aws_lambda_powertools.utilities.typing import LambdaContext
app_config = AppConfigStore(
environment="dev",
application="product-catalogue",
name="feature_flags",
envelope="features",
)
feature_flags = FeatureFlags(store=app_config)
def lambda_handler(event: dict, context: LambdaContext):
apply_discount: Any = feature_flags.evaluate(name="ten_percent_off_campaign", default=False)
price: Any = event.get("price")
if apply_discount:
# apply 10% discount to product
price = price * 0.9
return {"price": price}
|