createEventBus method

Future<CreateEventBusResponse> createEventBus({
  1. required String name,
  2. DeadLetterConfig? deadLetterConfig,
  3. String? description,
  4. String? eventSourceName,
  5. String? kmsKeyIdentifier,
  6. LogConfig? logConfig,
  7. List<Tag>? tags,
})

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.

May throw ConcurrentModificationException. May throw InternalException. May throw InvalidStateException. May throw LimitExceededException. May throw OperationDisabledException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException.

Parameter name : 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.

Parameter description : The event bus description.

Parameter eventSourceName : If you are creating a partner event bus, this specifies the partner event source that the new event bus will be matched with.

Parameter kmsKeyIdentifier : 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.

  • 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.

Implementation

Future<CreateEventBusResponse> createEventBus({
  required String name,
  DeadLetterConfig? deadLetterConfig,
  String? description,
  String? eventSourceName,
  String? kmsKeyIdentifier,
  LogConfig? logConfig,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSEvents.CreateEventBus'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      if (deadLetterConfig != null) 'DeadLetterConfig': deadLetterConfig,
      if (description != null) 'Description': description,
      if (eventSourceName != null) 'EventSourceName': eventSourceName,
      if (kmsKeyIdentifier != null) 'KmsKeyIdentifier': kmsKeyIdentifier,
      if (logConfig != null) 'LogConfig': logConfig,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateEventBusResponse.fromJson(jsonResponse.body);
}