in src/lambda_functions/resource_name_cfn_cr/lambda_function.py [0:0]
def create_or_update_resource_name(event, _):
"""Create or Update Resource"""
resource_type = event["ResourceType"]
resource_properties = event["ResourceProperties"]
if resource_type == "Custom::ResourceName":
bot_id = resource_properties["BotId"]
bot_locale_id = resource_properties["BotLocaleId"]
stack_name = resource_properties["StackName"].removeprefix(SAR_STACK_PREFIX)
try:
response = CLIENT.describe_bot(
botId=bot_id,
)
bot_name = response["botName"]
except Exception as exception: # pylint: disable=broad-except
LOGGER.error("failed to call describe_bot - exception: %s", exception)
raise
return f"{bot_name}-{bot_id}-{bot_locale_id}-{stack_name}"
raise ValueError(f"invalid resource type: {resource_type}")