You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With this library and its decorators, is it possible to map the received events to multiple functions depending on their ResourceTypes?
For instance. I imagine multiple function definitions annotated with @helper.create and make CfnResource can decide which one to run depending on the resource type.
is it possible this way or in some other manner?
The text was updated successfully, but these errors were encountered:
supporting multiple resource types with a single lambda is not supported in the library currently. You could easily create a wrapper that fans out to multiple lambdas depending on type, something like:
importboto3importjsonfromcrhelperimportCfnResourceimportlogginglogger=logging.getLogger(__name__)
# Initialise the helper, all inputs are optional, this example shows the defaultshelper=CfnResource(json_logging=False, log_level='DEBUG', boto_level='CRITICAL')
try:
HANDLER_MAP= {
"Custom::SomeType": "SomeType-function",
"Custom::SomeOtherType": "SomeOtherType-function"
}
lambda_client=boto3.client('lambda')
exceptExceptionase:
helper.init_failure(e)
@helper.create@helper.update@helper.deletedefhandler(event, context):
func_name=HANDLER_MAP[event['ResourceType']]
lambda_client.invoke(FunctionName=func_name, InvocationType='Event', Payload=json.dumps(event))
crhelper can be implemented in the target functions as if they were being invoked directly by cloudformation
With this library and its decorators, is it possible to map the received events to multiple functions depending on their
ResourceType
s?For instance. I imagine multiple function definitions annotated with
@helper.create
and makeCfnResource
can decide which one to run depending on the resource type.is it possible this way or in some other manner?
The text was updated successfully, but these errors were encountered: