def create()

in cloudformation/functions/source/database-resource-id-custom-resource/app.py [0:0]


def create(event, context):
    logger.info("Got Create")
    # Optionally return an ID that will be used for the resource PhysicalResourceId, 
    # if None is returned an ID will be generated. If a poll_create function is defined 
    # return value is placed into the poll event as event['CrHelperData']['PhysicalResourceId']
    #
    # To add response data update the helper.Data dict
    # If poll is enabled data is placed into poll event as event['CrHelperData']
    database_resource_id=None
    if 'DBClusterIdentifier' in event['ResourceProperties']:
        logger.info("cluster type")
        response = rds.describe_db_clusters(
                DBClusterIdentifier=event['ResourceProperties']['DBClusterIdentifier']
        )
        database_resource_id=response['DBClusters'][0]['DbClusterResourceId']
    else:
        logger.info("instance type")
        response = rds.describe_db_instances(
            DBInstanceIdentifier=event['ResourceProperties']['DatabaseInstanceId']
        )
        database_resource_id=response["DBInstances"][0]["DbiResourceId"]

    logger.info("DbiResourceId={}".format(database_resource_id))
    helper.Data.update({"DbiResourceId": database_resource_id})
    return None