Skip to content

create_listener

create_listener(
    service_identifier: ServiceIdentifier,
    name: ListenerName,
    protocol: ListenerProtocol,
    default_action: RuleAction,
    *,
    config_overrides: Optional[VPCLatticeClientConfig] = None,
    port: Optional[Port] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagMap] = None,
) -> CreateListenerResponse

Creates a listener for a service. Before you start using your Amazon VPC Lattice service, you must add one or more listeners. A listener is a process that checks for connection requests to your services. For more information, see Listeners in the Amazon VPC Lattice User Guide.

Parameters:

  • service_identifier (ServiceIdentifier) –

    The ID or ARN of the service.

  • name (ListenerName) –

    The name of the listener. A listener name must be unique within a service. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.

  • protocol (ListenerProtocol) –

    The listener protocol.

  • port (Optional[Port], default: None ) –

    The listener port. You can specify a value from 1 to 65535. For HTTP, the default is 80. For HTTPS, the default is 443.

  • default_action (RuleAction) –

    The action for the default rule. Each listener has a default rule. The default rule is used if no other rules match.

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.

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

    The tags for the listener.

Raises:

Source code in docs_src/capo_vpc_lattice/_services/vpc_lattice.py
def create_listener(
    self,
    service_identifier: "capo_vpc_lattice.types.service_identifier.ServiceIdentifier",
    name: "capo_vpc_lattice.types.listener_name.ListenerName",
    protocol: "capo_vpc_lattice.types.listener_protocol.ListenerProtocol",
    default_action: "capo_vpc_lattice.types.rule_action.RuleAction",
    *,
    config_overrides: Optional[VPCLatticeClientConfig] = None,
    port: Optional["capo_vpc_lattice.types.port.Port"] = None,
    client_token: Optional[
        "capo_vpc_lattice.types.client_token.ClientToken"
    ] = None,
    tags: Optional["capo_vpc_lattice.types.tag_map.TagMap"] = None,
) -> "capo_vpc_lattice.types.create_listener_response.CreateListenerResponse":
    """<p>Creates a listener for a service. Before you start using your Amazon VPC Lattice service, you must add one or more listeners. A listener is a process that checks for connection requests to your services. For more information, see <a href="https://docs.aws.amazon.com/vpc-lattice/latest/ug/listeners.html">Listeners</a> in the <i>Amazon VPC Lattice User Guide</i>.</p>

    Args:
        service_identifier: <p>The ID or ARN of the service.</p>
        name: <p>The name of the listener. A listener name must be unique within a service. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.</p>
        protocol: <p>The listener protocol.</p>
        port: <p>The listener port. You can specify a value from 1 to 65535. For HTTP, the default is 80. For HTTPS, the default is 443.</p>
        default_action: <p>The action for the default rule. Each listener has a default rule. The default rule is used if no other rules match.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.</p>
        tags: <p>The tags for the listener.</p>

    Raises:
        capo_vpc_lattice.errors.access_denied_exception.AccessDeniedException: <p>The user does not have sufficient access to perform this action.</p>
        capo_vpc_lattice.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Updating or deleting a resource can cause an inconsistent state.</p>
        capo_vpc_lattice.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred while processing the request.</p>
        capo_vpc_lattice.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource that does not exist.</p>
        capo_vpc_lattice.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p>
        capo_vpc_lattice.errors.throttling_exception.ThrottlingException: <p>The limit on the number of requests per second was exceeded.</p>
        capo_vpc_lattice.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_vpc_lattice.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_vpc_lattice.types.create_listener_request.CreateListenerRequest]",
    ) -> OperationResponse[
        "capo_vpc_lattice.types.create_listener_response.CreateListenerResponse"
    ]:
        import capo_vpc_lattice._operations.mercury_control_plane.create_listener

        output, http_response = (
            capo_vpc_lattice._operations.mercury_control_plane.create_listener.create_listener(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateListener")
    )
    input_: capo_vpc_lattice.types.create_listener_request.CreateListenerRequest = {
        "service_identifier": service_identifier,
        "name": name,
        "protocol": protocol,
        "default_action": default_action,
    }
    if port is not None:
        input_["port"] = port
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

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