Skip to content

create_mount_target

create_mount_target(
    file_system_id: FileSystemId,
    subnet_id: SubnetId,
    *,
    config_overrides: Optional[EFSClientConfig] = None,
    ip_address: Optional[IpAddress] = None,
    ipv6_address: Optional[Ipv6Address] = None,
    ip_address_type: Optional[IpAddressType] = None,
    security_groups: Optional[SecurityGroups] = None,
) -> MountTargetDescription

Creates a mount target for a file system. You can then mount the file system on EC2 instances by using the mount target. For more information about mount targets, see Managing mount targets.

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

After creating the mount target, Amazon EFS returns a response that includes a MountTargetId and an IP address (IpAddress or Ipv6Address). You use this IP address when mounting the file system in an EC2 instance. You can also use the mount target's DNS name when mounting the file system. The EC2 instance on which you mount the file system by using the mount target can resolve the mount target's DNS name to its IP address. For more information, see How Amazon EFS works.

Note that you can create mount targets for a file system in only one VPC, and there can be only one mount target per Availability Zone. For more information, see Creating mount targets.

If the request satisfies the requirements, Amazon EFS does the following:

  • Creates a new mount target in the specified subnet.

  • Creates a new network interface in the subnet with the folowing:

    • The description Mount target fsmt-id for file system fs-id where fsmt-id is the mount target ID, and fs-id is the FileSystemId.

    • The requesterManaged property of the network interface set to true, and the requesterId value set to EFS.

    Each mount target has one corresponding requester-managed EC2 network interface. After the network interface is created, Amazon EFS sets the NetworkInterfaceId field in the mount target's description to the network interface ID, and the IP address to its address. If network interface creation fails, the entire CreateMountTarget operation fails.

The CreateMountTarget call returns only after creating the network interface, but while the mount target state is still creating, you can check the mount target creation status by calling the DescribeMountTargets operation, which among other things returns the mount target state.

This operation requires permissions for the following action on the file system:

  • elasticfilesystem:CreateMountTarget

Unless you use the Amazon EFS service-linked role, which performs these actions on your behalf by default, this operation also requires permissions for the following Amazon EC2 actions:

  • ec2:DescribeSubnets

  • ec2:DescribeNetworkInterfaces

  • ec2:CreateNetworkInterface

Parameters:

  • file_system_id (FileSystemId) –

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

  • subnet_id (SubnetId) –

    The ID of the subnet to add the mount target in. For One Zone file systems, use the subnet that is associated with the file system's Availability Zone. The subnet type must be the same type as the IpAddressType.

  • ip_address (Optional[IpAddress], default: None ) –

    If the IpAddressType for the mount target is IPv4 ( IPV4_ONLY or DUAL_STACK), then specify the IPv4 address to use. If you do not specify an IpAddress, then Amazon EFS selects an unused IP address from the subnet specified for SubnetId.

  • ipv6_address (Optional[Ipv6Address], default: None ) –

    If the IPAddressType for the mount target is IPv6 (IPV6_ONLY or DUAL_STACK), then specify the IPv6 address to use. If you do not specify an Ipv6Address, then Amazon EFS selects an unused IP address from the subnet specified for SubnetId.

  • ip_address_type (Optional[IpAddressType], default: None ) –

    The IP address type for the mount target. The possible values are IPV4_ONLY (only IPv4 addresses), IPV6_ONLY (only IPv6 addresses), and DUAL_STACK (dual-stack, both IPv4 and IPv6 addresses). If you don’t specify an IpAddressType, then IPV4_ONLY is used.

    The IPAddressType must match the IP type of the subnet. Additionally, the IPAddressType parameter overrides the value set as the default IP address for the subnet in the VPC. For example, if the IPAddressType is IPV4_ONLY and AssignIpv6AddressOnCreation is true, then IPv4 is used for the mount target. For more information, see Modify the IP addressing attributes of your subnet.

  • security_groups (Optional[SecurityGroups], default: None ) –

    VPC security group IDs, of the form sg-xxxxxxxx. These must be for the same VPC as the subnet specified. The maximum number of security groups depends on account quota. For more information, see Amazon VPC Quotas in the Amazon VPC User Guide (see the Security Groups table). If you don't specify a security group, then Amazon EFS uses the default security group for the subnet's VPC.

Raises:

  • AvailabilityZonesMismatch –

    Returned if the Availability Zone that was specified for the mount target is different from the file system's Availability Zone. For more information, see Regional and One Zone storage redundancy.

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

  • IpAddressInUse –

    Returned if the request specified an IP address (IpAddress or Ipv6Address) that is already in use in the subnet.

  • MountTargetConflict –

    Returned if the mount target would violate one of the specified restrictions based on the file system's existing mount targets.

  • NetworkInterfaceLimitExceeded –

    The calling account has reached the limit for elastic network interfaces for the specific Amazon Web Services Region. Either delete some network interfaces or request that the account quota be raised. For more information, see Amazon VPC Quotas in the Amazon VPC User Guide (see the Network interfaces per Region entry in the Network interfaces table).

  • NoFreeAddressesInSubnet –

    Returned no IpAddress or Ipv6Address was provided in the request and there are no free IP addresses in the specified subnet.

  • SecurityGroupLimitExceeded –

    Returned if the number of SecurityGroups specified in the request is greater than the limit, which is based on account quota. Either delete some security groups or request that the account quota be raised. For more information, see Amazon VPC Quotas in the Amazon VPC User Guide (see the Security Groups table).

  • SecurityGroupNotFound –

    Returned if one of the specified security groups doesn't exist in the subnet's virtual private cloud (VPC).

  • SubnetNotFound –

    Returned if there is no subnet with ID SubnetId provided in the request.

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

  • UnsupportedAvailabilityZone –

    Returned if the requested Amazon EFS functionality is not available in the specified Availability Zone.

  • UnknownServiceError –

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

Examples:

To create a new mount target This operation creates a new mount target for an EFS file system.

>>> client.create_mount_target(file_system_id='fs-01234567', subnet_id='subnet-1234abcd')
Source code in docs_src/capo_efs/_services/efs.py
def create_mount_target(
    self,
    file_system_id: "capo_efs.types.file_system_id.FileSystemId",
    subnet_id: "capo_efs.types.subnet_id.SubnetId",
    *,
    config_overrides: Optional[EFSClientConfig] = None,
    ip_address: Optional["capo_efs.types.ip_address.IpAddress"] = None,
    ipv6_address: Optional["capo_efs.types.ipv6_address.Ipv6Address"] = None,
    ip_address_type: Optional[
        "capo_efs.types.ip_address_type.IpAddressType"
    ] = None,
    security_groups: Optional[
        "capo_efs.types.security_groups.SecurityGroups"
    ] = None,
) -> "capo_efs.types.mount_target_description.MountTargetDescription":
    """<p>Creates a mount target for a file system. You can then mount the file system on EC2 instances by using the mount target. For more information about mount targets, see <a href="https://docs.aws.amazon.com/efs/latest/ug/accessing-fs.html">Managing mount targets</a>. </p> <p>To create a mount target for an EFS file system, the file system's lifecycle state must be <code>available</code>. For more information, see <a>DescribeFileSystems</a>.</p> <p>After creating the mount target, Amazon EFS returns a response that includes a <code>MountTargetId</code> and an IP address (<code>IpAddress</code> or <code>Ipv6Address</code>). You use this IP address when mounting the file system in an EC2 instance. You can also use the mount target's DNS name when mounting the file system. The EC2 instance on which you mount the file system by using the mount target can resolve the mount target's DNS name to its IP address. For more information, see <a href="https://docs.aws.amazon.com/efs/latest/ug/how-it-works.html">How Amazon EFS works</a>. </p> <p>Note that you can create mount targets for a file system in only one VPC, and there can be only one mount target per Availability Zone. For more information, see <a href="https://docs.aws.amazon.com/efs/latest/ug/manage-fs-access-create-delete-mount-targets.html">Creating mount targets</a>.</p> <p>If the request satisfies the requirements, Amazon EFS does the following:</p> <ul> <li> <p>Creates a new mount target in the specified subnet.</p> </li> <li> <p>Creates a new network interface in the subnet with the folowing:</p> <ul> <li> <p>The description <code>Mount target <i>fsmt-id</i> for file system <i>fs-id</i> </code> where <code> <i>fsmt-id</i> </code> is the mount target ID, and <code> <i>fs-id</i> </code> is the <code>FileSystemId</code>.</p> </li> <li> <p>The <code>requesterManaged</code> property of the network interface set to <code>true</code>, and the <code>requesterId</code> value set to <code>EFS</code>.</p> </li> </ul> <p>Each mount target has one corresponding requester-managed EC2 network interface. After the network interface is created, Amazon EFS sets the <code>NetworkInterfaceId</code> field in the mount target's description to the network interface ID, and the IP address to its address. If network interface creation fails, the entire <code>CreateMountTarget</code> operation fails.</p> </li> </ul> <note> <p>The <code>CreateMountTarget</code> call returns only after creating the network interface, but while the mount target state is still <code>creating</code>, you can check the mount target creation status by calling the <a>DescribeMountTargets</a> operation, which among other things returns the mount target state.</p> </note> <p>This operation requires permissions for the following action on the file system:</p> <ul> <li> <p> <code>elasticfilesystem:CreateMountTarget</code> </p> </li> </ul> <p>Unless you use the <a href="https://docs.aws.amazon.com/efs/latest/ug/using-service-linked-roles.html">Amazon EFS service-linked role</a>, which performs these actions on your behalf by default, this operation also requires permissions for the following Amazon EC2 actions:</p> <ul> <li> <p> <code>ec2:DescribeSubnets</code> </p> </li> <li> <p> <code>ec2:DescribeNetworkInterfaces</code> </p> </li> <li> <p> <code>ec2:CreateNetworkInterface</code> </p> </li> </ul>

    Args:
        file_system_id: <p>The ID of the file system for which to create the mount target.</p>
        subnet_id: <p>The ID of the subnet to add the mount target in. For One Zone file systems, use the subnet that is associated with the file system's Availability Zone. The subnet type must be the same type as the <code>IpAddressType</code>.</p>
        ip_address: <p>If the <code>IpAddressType</code> for the mount target is IPv4 ( <code>IPV4_ONLY</code> or <code>DUAL_STACK</code>), then specify the IPv4 address to use. If you do not specify an <code>IpAddress</code>, then Amazon EFS selects an unused IP address from the subnet specified for <code>SubnetId</code>.</p>
        ipv6_address: <p>If the <code>IPAddressType</code> for the mount target is IPv6 (<code>IPV6_ONLY</code> or <code>DUAL_STACK</code>), then specify the IPv6 address to use. If you do not specify an <code>Ipv6Address</code>, then Amazon EFS selects an unused IP address from the subnet specified for <code>SubnetId</code>.</p>
        ip_address_type: <p>The IP address type for the mount target. The possible values are <code>IPV4_ONLY</code> (only IPv4 addresses), <code>IPV6_ONLY</code> (only IPv6 addresses), and <code>DUAL_STACK</code> (dual-stack, both IPv4 and IPv6 addresses). If you don’t specify an <code>IpAddressType</code>, then <code>IPV4_ONLY</code> is used.</p> <note> <p>The <code>IPAddressType</code> must match the IP type of the subnet. Additionally, the <code>IPAddressType</code> parameter overrides the value set as the default IP address for the subnet in the VPC. For example, if the <code>IPAddressType</code> is <code>IPV4_ONLY</code> and <code>AssignIpv6AddressOnCreation</code> is <code>true</code>, then IPv4 is used for the mount target. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/subnet-public-ip.html">Modify the IP addressing attributes of your subnet</a>.</p> </note>
        security_groups: <p>VPC security group IDs, of the form <code>sg-xxxxxxxx</code>. These must be for the same VPC as the subnet specified. The maximum number of security groups depends on account quota. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html">Amazon VPC Quotas</a> in the <i>Amazon VPC User Guide</i> (see the <b>Security Groups</b> table). If you don't specify a security group, then Amazon EFS uses the default security group for the subnet's VPC.</p>

    Raises:
        capo_efs.errors.availability_zones_mismatch.AvailabilityZonesMismatch: <p>Returned if the Availability Zone that was specified for the mount target is different from the file system's Availability Zone. For more information, see <a href="https://docs.aws.amazon.com/efs/latest/ug/accessing-fs">Regional and One Zone storage redundancy</a>.</p>
        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.ip_address_in_use.IpAddressInUse: <p>Returned if the request specified an IP address (<code>IpAddress</code> or <code>Ipv6Address</code>) that is already in use in the subnet.</p>
        capo_efs.errors.mount_target_conflict.MountTargetConflict: <p>Returned if the mount target would violate one of the specified restrictions based on the file system's existing mount targets.</p>
        capo_efs.errors.network_interface_limit_exceeded.NetworkInterfaceLimitExceeded: <p>The calling account has reached the limit for elastic network interfaces for the specific Amazon Web Services Region. Either delete some network interfaces or request that the account quota be raised. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html">Amazon VPC Quotas</a> in the <i>Amazon VPC User Guide</i> (see the <b>Network interfaces per Region</b> entry in the <b>Network interfaces</b> table). </p>
        capo_efs.errors.no_free_addresses_in_subnet.NoFreeAddressesInSubnet: <p>Returned no <code>IpAddress</code> or <code>Ipv6Address</code> was provided in the request and there are no free IP addresses in the specified subnet.</p>
        capo_efs.errors.security_group_limit_exceeded.SecurityGroupLimitExceeded: <p>Returned if the number of <code>SecurityGroups</code> specified in the request is greater than the limit, which is based on account quota. Either delete some security groups or request that the account quota be raised. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html">Amazon VPC Quotas</a> in the <i>Amazon VPC User Guide</i> (see the <b>Security Groups</b> table). </p>
        capo_efs.errors.security_group_not_found.SecurityGroupNotFound: <p>Returned if one of the specified security groups doesn't exist in the subnet's virtual private cloud (VPC).</p>
        capo_efs.errors.subnet_not_found.SubnetNotFound: <p>Returned if there is no subnet with ID <code>SubnetId</code> provided in the request.</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.unsupported_availability_zone.UnsupportedAvailabilityZone: <p>Returned if the requested Amazon EFS functionality is not available in the specified Availability Zone.</p>
        capo_efs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a new mount target
        This operation creates a new mount target for an EFS file system.

        >>> client.create_mount_target(file_system_id='fs-01234567', subnet_id='subnet-1234abcd')
    """

    def _handler(
        req: "OperationRequest[capo_efs.types.create_mount_target_request.CreateMountTargetRequest]",
    ) -> OperationResponse[
        "capo_efs.types.mount_target_description.MountTargetDescription"
    ]:
        import capo_efs._operations.magnolio_api_service_v20150201.create_mount_target

        output, http_response = (
            capo_efs._operations.magnolio_api_service_v20150201.create_mount_target.create_mount_target(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateMountTarget")
    )
    input_: capo_efs.types.create_mount_target_request.CreateMountTargetRequest = {
        "file_system_id": file_system_id,
        "subnet_id": subnet_id,
    }
    if ip_address is not None:
        input_["ip_address"] = ip_address
    if ipv6_address is not None:
        input_["ipv6_address"] = ipv6_address
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type
    if security_groups is not None:
        input_["security_groups"] = security_groups

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