Skip to content

create_event_source

create_event_source(
    name: EventSourceName,
    event_bus_arn: EventBusArn,
    configuration: EventSourceConfiguration,
    *,
    config_overrides: Optional[EventBridgeV2ClientConfig] = None,
    description: Optional[Description] = None,
    tags: Optional[TagMap] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateEventSourceResponse

Creates an EventSource, which forwards events from an origin (an AWS service, a partner, or a third-party webhook provider) to an event bus. The event bus must be in the ACTIVE state. This operation is idempotent: retries that use the same ClientToken return the same result.

Parameters:

  • name (EventSourceName) –

    EventSource name. First character alphanumeric; the rest may add '.', '-', '_'. Names may not begin with the reserved "aws." prefix. The grammar matches the ARN local-name segment in EventSourceArn (event-sourcev2/<type>/<name>/<id>), mirroring EventBusName, so a name the ARN cannot represent cannot be created.

  • event_bus_arn (EventBusArn) –

    The Amazon Resource Name (ARN) that uniquely identifies an event bus.

  • configuration (EventSourceConfiguration) –

    Discriminated EventSource configuration. Exactly one variant must be set.

  • description (Optional[Description], default: None ) –

    Free-text description. Used by every resource type that has one: event buses, subscribers, and event sources.

  • tags (Optional[TagMap], default: None ) –

    Tags attached to a resource, as key-value pairs.

  • client_token (Optional[ClientToken], default: None ) –

    Unique, case-sensitive identifier that ensures the idempotency of the request. The SDK generates one automatically when the field is omitted.

Raises:

Source code in docs_src/capo_eventbridgev2/_services/event_bridge_v2.py
def create_event_source(
    self,
    name: "capo_eventbridgev2.types.event_source_name.EventSourceName",
    event_bus_arn: "capo_eventbridgev2.types.event_bus_arn.EventBusArn",
    configuration: "capo_eventbridgev2.types.event_source_configuration.EventSourceConfiguration",
    *,
    config_overrides: Optional[EventBridgeV2ClientConfig] = None,
    description: Optional[
        "capo_eventbridgev2.types.description.Description"
    ] = None,
    tags: Optional["capo_eventbridgev2.types.tag_map.TagMap"] = None,
    client_token: Optional[
        "capo_eventbridgev2.types.client_token.ClientToken"
    ] = None,
) -> "capo_eventbridgev2.types.create_event_source_response.CreateEventSourceResponse":
    """<p>Creates an EventSource, which forwards events from an origin (an AWS service, a partner, or a third-party webhook provider) to an event bus. The event bus must be in the ACTIVE state. This operation is idempotent: retries that use the same ClientToken return the same result.</p>

    Args:
        name: <p>EventSource name. First character alphanumeric; the rest may add '.', '-', '_'. Names may not begin with the reserved "aws." prefix. The grammar matches the ARN local-name segment in EventSourceArn (event-sourcev2/&lt;type&gt;/&lt;name&gt;/&lt;id&gt;), mirroring EventBusName, so a name the ARN cannot represent cannot be created.</p>
        event_bus_arn: <p>The Amazon Resource Name (ARN) that uniquely identifies an event bus.</p>
        configuration: <p>Discriminated EventSource configuration. Exactly one variant must be set.</p>
        description: <p>Free-text description. Used by every resource type that has one: event buses, subscribers, and event sources.</p>
        tags: <p>Tags attached to a resource, as key-value pairs.</p>
        client_token: <p>Unique, case-sensitive identifier that ensures the idempotency of the request. The SDK generates one automatically when the field is omitted.</p>

    Raises:
        capo_eventbridgev2.errors.access_denied_exception.AccessDeniedException: <p>The caller does not have the permissions required to perform the operation. This error is also returned when the operation cannot use the AWS KMS key for the event bus.</p>
        capo_eventbridgev2.errors.internal_exception.InternalException: <p>The request failed because of an internal service error. Retry the request.</p>
        capo_eventbridgev2.errors.invalid_input_exception.InvalidInputException: <p>A request parameter is missing or not valid.</p>
        capo_eventbridgev2.errors.throttling_exception.ThrottlingException: <p>The request was throttled because it exceeds a request rate limit. Retry the request with backoff.</p>
        capo_eventbridgev2.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Another change to the resource is already in progress. Retry the request.</p>
        capo_eventbridgev2.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>The request reuses the client token of an earlier request with different parameters. Use a new client token, or resend the earlier request unchanged.</p>
        capo_eventbridgev2.errors.invalid_state_exception.InvalidStateException: <p>The resource is not in a state that allows the operation. For example, an event bus that is still being created cannot accept events.</p>
        capo_eventbridgev2.errors.limit_exceeded_exception.LimitExceededException: <p>The request would exceed a service quota for the account.</p>
        capo_eventbridgev2.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>A resource with the same name already exists.</p>
        capo_eventbridgev2.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource does not exist.</p>
        capo_eventbridgev2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_eventbridgev2.types.create_event_source_request.CreateEventSourceRequest]",
    ) -> OperationResponse[
        "capo_eventbridgev2.types.create_event_source_response.CreateEventSourceResponse"
    ]:
        import capo_eventbridgev2._operations.aws_events_v2.create_event_source

        output, http_response = (
            capo_eventbridgev2._operations.aws_events_v2.create_event_source.create_event_source(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_eventbridgev2.types.create_event_source_request.CreateEventSourceRequest",
    ) -> dict[str, Any]:
        import capo_eventbridgev2.types.create_event_source_request

        return (
            capo_eventbridgev2.types.create_event_source_request.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_eventbridgev2.types.create_event_source_response.CreateEventSourceResponse",
    ) -> dict[str, Any]:
        import capo_eventbridgev2.types.create_event_source_response

        return (
            capo_eventbridgev2.types.create_event_source_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateEventSource",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_eventbridgev2.types.create_event_source_request.CreateEventSourceRequest = {
        "name": name,
        "event_bus_arn": event_bus_arn,
        "configuration": configuration,
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output