Skip to content

EventBridge utility #1168

@stephenbawks

Description

@stephenbawks

Is your feature request related to a problem? Please describe.
What do you guys think of possibly adding some extra library type stuff for Eventbridge? Was thinking of a couple of super useful tools. One for calculating the size of an event:

def get_eventbridge_put_event_size(eventbridge_event: dict) -> int:
    """Calculating the size of the event in bytes
    https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-putevent-size.html

    Args:
        eventbridge_event (dict): Event to calculate size of in

    Returns:
        size (int): Size of the event in bytes
    """
    size = 0
    if eventbridge_event.get("time") is not None:
        size += 14
    size += len(eventbridge_event.get("source").encode("utf-8"))
    size += len(eventbridge_event.get("detail-type").encode("utf-8"))
    size += len(json.dumps(eventbridge_event.get("detail")).encode("utf-8"))
    for resource in eventbridge_event.get("resources", []):
        if resource:
            size += len(resource.encode("utf-8"))
    print("Event Size: " + str(size) + " bytes")
    return size

Was also thinking about adding some additional functionality for if a message size is above the 256k mark you can have it auto-truncate and have it drop to a S3 bucket and have it then create a presigned URL.

Couple of those for starters would be awesome since I can see myself using both of those more and more often.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestfeature requesthelp wantedCould use a second pair of eyes/handsneed-customer-feedbackRequires more customers feedback before making or revisiting a decision

    Type

    No type

    Projects

    Status

    Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions