Skip to content

How do I set the log destinations of event bus logs using boto3?

0

The feature is described @ https://aws.amazon.com/blogs/aws/monitor-and-debug-event-driven-applications-with-new-amazon-eventbridge-logging/ and it shows the logs going to CloudWatch and S3 but there's nothing in https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/events/client/create_event_bus.html that lets me do this.

create_event_bus EventBridge.Client.create_event_bus(**kwargs) Creates a new event bus within your account. This can be a custom event bus which you can use to receive events from your custom applications and services, or it can be a partner event bus which can be matched to a partner event source.

See also: AWS API Documentation

Request Syntax response = client.create_event_bus( Name='string', EventSourceName='string', Description='string', KmsKeyIdentifier='string', DeadLetterConfig={ 'Arn': 'string' }, LogConfig={ 'IncludeDetail': 'NONE'|'FULL', 'Level': 'OFF'|'ERROR'|'INFO'|'TRACE' }, Tags=[ { 'Key': 'string', 'Value': 'string' }, ] ) Parameters: Name (string) –

[REQUIRED]

The name of the new event bus.

Custom event bus names can’t contain the / character, but you can use the / character in partner event bus names. In addition, for partner event buses, the name must exactly match the name of the partner event source that this event bus is matched to.

You can’t use the name default for a custom event bus, as this name is already used for your account’s default event bus.

EventSourceName (string) – If you are creating a partner event bus, this specifies the partner event source that the new event bus will be matched with.

Description (string) – The event bus description.

KmsKeyIdentifier (string) –

The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt events on this event bus. The identifier can be the key Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN.

If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt events on the event bus.

For more information, see Identify and view keys in the Key Management Service Developer Guide.

Note Schema discovery is not supported for event buses encrypted using a customer managed key. EventBridge returns an error if:

You call CreateDiscoverer on an event bus set to use a customer managed key for encryption.

You call UpdatedEventBus to set a customer managed key on an event bus with schema discovery enabled.

To enable schema discovery on an event bus, choose to use an Amazon Web Services owned key. For more information, see Encrypting events in the Amazon EventBridge User Guide.

Warning If you have specified that EventBridge use a customer managed key for encrypting the source event bus, we strongly recommend you also specify a customer managed key for any archives for the event bus as well.

For more information, see Encrypting archives in the Amazon EventBridge User Guide.

DeadLetterConfig (dict) –

Configuration details of the Amazon SQS queue for EventBridge to use as a dead-letter queue (DLQ).

For more information, see Using dead-letter queues to process undelivered events in the EventBridge User Guide.

Arn (string) –

The ARN of the SQS queue specified as the target for the dead-letter queue.

LogConfig (dict) –

The logging configuration settings for the event bus.

For more information, see Configuring logs for event buses in the EventBridge User Guide.

IncludeDetail (string) –

Whether EventBridge include detailed event information in the records it generates. Detailed data can be useful for troubleshooting and debugging. This information includes details of the event itself, as well as target details.

For more information, see Including detail data in event bus logs in the EventBridge User Guide.

Level (string) –

The level of logging detail to include. This applies to all log destinations for the event bus.

For more information, see Specifying event bus log level in the EventBridge User Guide.

Tags (list) –

Tags to associate with the event bus.

(dict) –

A key-value pair associated with an Amazon Web Services resource. In EventBridge, rules and event buses support tagging.

Key (string) – [REQUIRED]

A string you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.

Value (string) – [REQUIRED]

The value for the specified tag key.

Return type: dict

Returns: Response Syntax { 'EventBusArn': 'string', 'Description': 'string', 'KmsKeyIdentifier': 'string', 'DeadLetterConfig': { 'Arn': 'string' }, 'LogConfig': { 'IncludeDetail': 'NONE'|'FULL', 'Level': 'OFF'|'ERROR'|'INFO'|'TRACE' } } Response Structure (dict) –

EventBusArn (string) –

The ARN of the new event bus.

Description (string) –

The event bus description.

KmsKeyIdentifier (string) –

The identifier of the KMS customer managed key for EventBridge to use to encrypt events on this event bus, if one has been specified.

For more information, see Data encryption in EventBridge in the Amazon EventBridge User Guide.

DeadLetterConfig (dict) –

Configuration details of the Amazon SQS queue for EventBridge to use as a dead-letter queue (DLQ).

For more information, see Using dead-letter queues to process undelivered events in the EventBridge User Guide.

Arn (string) –

The ARN of the SQS queue specified as the target for the dead-letter queue.

LogConfig (dict) –

The logging configuration settings for the event bus.

For more information, see Configuring logs for event buses in the EventBridge User Guide.

IncludeDetail (string) –

Whether EventBridge include detailed event information in the records it generates. Detailed data can be useful for troubleshooting and debugging. This information includes details of the event itself, as well as target details.

For more information, see Including detail data in event bus logs in the EventBridge User Guide.

Level (string) –

The level of logging detail to include. This applies to all log destinations for the event bus.

For more information, see Specifying event bus log level in the EventBridge User Guide.

Exceptions EventBridge.Client.exceptions.ResourceAlreadyExistsException

EventBridge.Client.exceptions.ResourceNotFoundException

EventBridge.Client.exceptions.InvalidStateException

EventBridge.Client.exceptions.InternalException

EventBridge.Client.exceptions.ConcurrentModificationException

EventBridge.Client.exceptions.LimitExceededException

EventBridge.Client.exceptions.OperationDisabledException

asked a year ago313 views

2 Answers
0

Hello.

Since it's still a new feature, I don't think it has been implemented in AWS APIs such as boto3 yet.
If you'd like to see this feature implemented sooner, I recommend submitting a request on boto3's GitHub.
https://github.com/boto/boto3/issues

EXPERT

answered a year ago

-2

Based on the information provided, when creating an event bus using boto3, you can configure the log level and whether to include detail data, but the actual log destinations (CloudWatch Logs, S3, or Firehose) are not directly specified in the create_event_bus API call.

The LogConfig parameter in the create_event_bus method only allows you to set:

  • Level: The logging detail level (OFF, ERROR, INFO, or TRACE)
  • IncludeDetail: Whether to include detailed event information (NONE or FULL)

To configure specific log destinations like CloudWatch Logs, S3, or Firehose for your event bus, you would need to use CloudWatch Logs vended logs capabilities after creating the event bus. This is because EventBridge uses CloudWatch Logs' delivery mechanisms to route logs to different destinations.

When you create an event bus with logging enabled, EventBridge creates a CloudWatch log group by default. To then route these logs to S3 or Firehose, you would need to configure CloudWatch Logs subscription filters or delivery destinations separately.

The process would involve:

  1. Create the event bus with logging enabled using the LogConfig parameter
  2. Configure CloudWatch Logs to deliver the logs to your desired destinations (S3 or Firehose)

Unfortunately, this cannot be done in a single boto3 call to create_event_bus - it requires additional CloudWatch Logs configuration steps.
Sources
Creating an event bus in Amazon EventBridge - Amazon EventBridge
Monitor and debug event-driven applications with new Amazon EventBridge logging | AWS News Blog
Amazon EventBridge now supports enhanced logging for improved observability - AWS
AWS Lambda introduces tiered pricing for Amazon CloudWatch logs and additional logging destinations | AWS Compute Blog

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.