Skip to content

create_connection

create_connection(
    name: ConnectionName,
    authorization_type: ConnectionAuthorizationType,
    auth_parameters: CreateConnectionAuthRequestParameters,
    *,
    config_overrides: Optional[EventBridgeClientConfig] = None,
    description: Optional[ConnectionDescription] = None,
    invocation_connectivity_parameters: Optional[ConnectivityResourceParameters] = None,
    kms_key_identifier: Optional[KmsKeyIdentifier] = None,
) -> CreateConnectionResponse

Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.

For more information, see Connections for endpoint targets in the Amazon EventBridge User Guide.

Parameters:

  • name (ConnectionName) –

    The name for the connection to create.

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

    A description for the connection to create.

  • authorization_type (ConnectionAuthorizationType) –

    The type of authorization to use for the connection.

    OAUTH tokens are refreshed when a 401 or 407 response is returned.

  • auth_parameters (CreateConnectionAuthRequestParameters) –

    The authorization parameters to use to authorize with the endpoint.

    You must include only authorization parameters for the AuthorizationType you specify.

  • invocation_connectivity_parameters (Optional[ConnectivityResourceParameters], default: None ) –

    For connections to private APIs, the parameters to use for invoking the API.

    For more information, see Connecting to private APIs in the Amazon EventBridge User Guide .

  • kms_key_identifier (Optional[KmsKeyIdentifier], default: None ) –

    The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt this connection. 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 the connection.

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

Raises:

Source code in docs_src/capo_eventbridge/_services/event_bridge.py
def create_connection(
    self,
    name: "capo_eventbridge.types.connection_name.ConnectionName",
    authorization_type: "capo_eventbridge.types.connection_authorization_type.ConnectionAuthorizationType",
    auth_parameters: "capo_eventbridge.types.create_connection_auth_request_parameters.CreateConnectionAuthRequestParameters",
    *,
    config_overrides: Optional[EventBridgeClientConfig] = None,
    description: Optional[
        "capo_eventbridge.types.connection_description.ConnectionDescription"
    ] = None,
    invocation_connectivity_parameters: Optional[
        "capo_eventbridge.types.connectivity_resource_parameters.ConnectivityResourceParameters"
    ] = None,
    kms_key_identifier: Optional[
        "capo_eventbridge.types.kms_key_identifier.KmsKeyIdentifier"
    ] = None,
) -> "capo_eventbridge.types.create_connection_response.CreateConnectionResponse":
    """<p>Creates a connection. A connection defines the authorization type and credentials to use for authorization with an API destination HTTP endpoint.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-target-connection.html">Connections for endpoint targets</a> in the <i>Amazon EventBridge User Guide</i>.</p>

    Args:
        name: <p>The name for the connection to create.</p>
        description: <p>A description for the connection to create.</p>
        authorization_type: <p>The type of authorization to use for the connection.</p> <note> <p>OAUTH tokens are refreshed when a 401 or 407 response is returned.</p> </note>
        auth_parameters: <p>The authorization parameters to use to authorize with the endpoint. </p> <p>You must include only authorization parameters for the <code>AuthorizationType</code> you specify.</p>
        invocation_connectivity_parameters: <p>For connections to private APIs, the parameters to use for invoking the API.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/connection-private.html">Connecting to private APIs</a> in the <i> <i>Amazon EventBridge User Guide</i> </i>.</p>
        kms_key_identifier: <p>The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt this connection. The identifier can be the key Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN.</p> <p>If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt the connection.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/viewing-keys.html">Identify and view keys</a> in the <i>Key Management Service Developer Guide</i>. </p>

    Raises:
        capo_eventbridge.errors.access_denied_exception.AccessDeniedException: <p>You do not have the necessary permissions for this action.</p>
        capo_eventbridge.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_eventbridge.errors.limit_exceeded_exception.LimitExceededException: <p>The request failed because it attempted to create resource beyond the allowed service quota.</p>
        capo_eventbridge.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource you are trying to create already exists.</p>
        capo_eventbridge.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
        capo_eventbridge.errors.throttling_exception.ThrottlingException: <p>This request cannot be completed due to throttling issues.</p>
        capo_eventbridge.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_eventbridge.types.create_connection_request.CreateConnectionRequest]",
    ) -> OperationResponse[
        "capo_eventbridge.types.create_connection_response.CreateConnectionResponse"
    ]:
        import capo_eventbridge._operations.aws_events.create_connection

        output, http_response = (
            capo_eventbridge._operations.aws_events.create_connection.create_connection(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_eventbridge.types.create_connection_request.CreateConnectionRequest",
    ) -> dict[str, Any]:
        import capo_eventbridge.types.create_connection_request

        return capo_eventbridge.types.create_connection_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateConnection", redact_input=_redact_input),
    )
    input_: capo_eventbridge.types.create_connection_request.CreateConnectionRequest = {
        "name": name,
        "authorization_type": authorization_type,
        "auth_parameters": auth_parameters,
    }
    if description is not None:
        input_["description"] = description
    if invocation_connectivity_parameters is not None:
        input_["invocation_connectivity_parameters"] = (
            invocation_connectivity_parameters
        )
    if kms_key_identifier is not None:
        input_["kms_key_identifier"] = kms_key_identifier

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