Skip to content

create_mount_session async

create_mount_session(
    file_system_id: FileSystemId,
    *,
    config_overrides: Optional[AsyncEFSClientConfig] = None,
    preferred_availability_zone_id: Optional[AvailabilityZoneId] = None,
    network_origin: Optional[NetworkOrigin] = None,
) -> CreateMountSessionResponse

Creates a mount session for an Amazon EFS file system and returns a set of endpoints that you can use to mount the file system. Each endpoint includes an IP address, a port, and a mount token that a client presents when it connects to the endpoint.

To create a mount session, the file system's lifecycle state must be available. For more information, see DescribeFileSystems.

This operation requires permissions for the elasticfilesystem:CreateMountSession action.

Parameters:

  • file_system_id (FileSystemId) –

    The ID of the file system for which to create the mount session.

  • preferred_availability_zone_id (Optional[AvailabilityZoneId], default: None ) –

    The ID of the Availability Zone (for example, use1-az1) in which you prefer the returned endpoints to be located. The Availability Zone must be in the same Amazon Web Services Region as the file system. This preference is best effort: if Amazon EFS can't provide an endpoint in the preferred Availability Zone, it returns endpoints in another Availability Zone instead of failing the request. If you don't specify a value, Amazon EFS returns endpoints without an Availability Zone preference.

  • network_origin (Optional[NetworkOrigin], default: None ) –

    Indicates whether the client connects to the file system from within the Amazon Web Services Cloud (AWS_NETWORK). External network (EXTERNAL_NETWORK) connections are not supported.

Raises:

  • BadRequest –

    Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.

  • FileSystemNotFound –

    Returned if the specified FileSystemId value doesn't exist in the requester's Amazon Web Services account.

  • IncorrectFileSystemLifeCycleState –

    Returned if the file system's lifecycle state is not "available".

  • InternalServerError –

    Returned if an error occurred on the server side.

  • ThrottlingException –

    Returned when the CreateAccessPoint API action is called too quickly and the number of Access Points on the file system is nearing the limit of 120.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_efs/_services/async_efs.py
async def create_mount_session(
    self,
    file_system_id: "capo_efs.types.file_system_id.FileSystemId",
    *,
    config_overrides: Optional[AsyncEFSClientConfig] = None,
    preferred_availability_zone_id: Optional[
        "capo_efs.types.availability_zone_id.AvailabilityZoneId"
    ] = None,
    network_origin: Optional["capo_efs.types.network_origin.NetworkOrigin"] = None,
) -> "capo_efs.types.create_mount_session_response.CreateMountSessionResponse":
    """<p>Creates a mount session for an Amazon EFS file system and returns a set of endpoints that you can use to mount the file system. Each endpoint includes an IP address, a port, and a mount token that a client presents when it connects to the endpoint.</p> <p>To create a mount session, the file system's lifecycle state must be <code>available</code>. For more information, see <a>DescribeFileSystems</a>.</p> <p>This operation requires permissions for the <code>elasticfilesystem:CreateMountSession</code> action.</p>

    Args:
        file_system_id: <p>The ID of the file system for which to create the mount session.</p>
        preferred_availability_zone_id: <p>The ID of the Availability Zone (for example, <code>use1-az1</code>) in which you prefer the returned endpoints to be located. The Availability Zone must be in the same Amazon Web Services Region as the file system. This preference is best effort: if Amazon EFS can't provide an endpoint in the preferred Availability Zone, it returns endpoints in another Availability Zone instead of failing the request. If you don't specify a value, Amazon EFS returns endpoints without an Availability Zone preference.</p>
        network_origin: <p>Indicates whether the client connects to the file system from within the Amazon Web Services Cloud (<code>AWS_NETWORK</code>). External network (<code>EXTERNAL_NETWORK</code>) connections are not supported.</p>

    Raises:
        capo_efs.errors.bad_request.BadRequest: <p>Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter.</p>
        capo_efs.errors.file_system_not_found.FileSystemNotFound: <p>Returned if the specified <code>FileSystemId</code> value doesn't exist in the requester's Amazon Web Services account.</p>
        capo_efs.errors.incorrect_file_system_life_cycle_state.IncorrectFileSystemLifeCycleState: <p>Returned if the file system's lifecycle state is not "available".</p>
        capo_efs.errors.internal_server_error.InternalServerError: <p>Returned if an error occurred on the server side.</p>
        capo_efs.errors.throttling_exception.ThrottlingException: <p>Returned when the <code>CreateAccessPoint</code> API action is called too quickly and the number of Access Points on the file system is nearing the <a href="https://docs.aws.amazon.com/efs/latest/ug/limits.html#limits-efs-resources-per-account-per-region">limit of 120</a>.</p>
        capo_efs.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_efs.types.create_mount_session_request.CreateMountSessionRequest]",
    ) -> AsyncOperationResponse[
        "capo_efs.types.create_mount_session_response.CreateMountSessionResponse"
    ]:
        import capo_efs._operations.magnolio_api_service_v20150201.create_mount_session

        (
            output,
            http_response,
        ) = await capo_efs._operations.magnolio_api_service_v20150201.create_mount_session.async_create_mount_session(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_efs.types.create_mount_session_response.CreateMountSessionResponse",
    ) -> dict[str, Any]:
        import capo_efs.types.create_mount_session_response

        return capo_efs.types.create_mount_session_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateMountSession", redact_output=_redact_output),
    )
    input_: capo_efs.types.create_mount_session_request.CreateMountSessionRequest = {
        "file_system_id": file_system_id
    }
    if preferred_availability_zone_id is not None:
        input_["preferred_availability_zone_id"] = preferred_availability_zone_id
    if network_origin is not None:
        input_["network_origin"] = network_origin

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output