Skip to content

attach_network_interface async

attach_network_interface(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    network_card_index: Optional[Integer] = None,
    ena_srd_specification: Optional[EnaSrdSpecification] = None,
    ena_queue_count: Optional[Integer] = None,
    dry_run: Optional[Boolean] = None,
    network_interface_id: Optional[NetworkInterfaceId] = None,
    instance_id: Optional[InstanceId] = None,
    device_index: Optional[Integer] = None,
) -> AttachNetworkInterfaceResult

Attaches a network interface to an instance.

Parameters:

  • network_card_index (Optional[Integer], default: None ) –

    The index of the network card. Some instance types support multiple network cards. The primary network interface must be assigned to network card index 0. The default is network card index 0.

  • ena_srd_specification (Optional[EnaSrdSpecification], default: None ) –

    Configures ENA Express for the network interface that this action attaches to the instance.

  • ena_queue_count (Optional[Integer], default: None ) –

    The number of ENA queues to be created with the instance.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • network_interface_id (Optional[NetworkInterfaceId], default: None ) –

    The ID of the network interface.

  • instance_id (Optional[InstanceId], default: None ) –

    The ID of the instance.

  • device_index (Optional[Integer], default: None ) –

    The index of the device for the network interface attachment.

Raises:

Examples:

To attach a network interface to an instance This example attaches the specified network interface to the specified instance.

>>> await client.attach_network_interface(network_interface_id='eni-e5aa89a3', instance_id='i-1234567890abcdef0', device_index=1)
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def attach_network_interface(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    network_card_index: Optional["capo_ec2.types.integer.Integer"] = None,
    ena_srd_specification: Optional[
        "capo_ec2.types.ena_srd_specification.EnaSrdSpecification"
    ] = None,
    ena_queue_count: Optional["capo_ec2.types.integer.Integer"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    network_interface_id: Optional[
        "capo_ec2.types.network_interface_id.NetworkInterfaceId"
    ] = None,
    instance_id: Optional["capo_ec2.types.instance_id.InstanceId"] = None,
    device_index: Optional["capo_ec2.types.integer.Integer"] = None,
) -> "capo_ec2.types.attach_network_interface_result.AttachNetworkInterfaceResult":
    """<p>Attaches a network interface to an instance.</p>

    Args:
        network_card_index: <p>The index of the network card. Some instance types support multiple network cards. The primary network interface must be assigned to network card index 0. The default is network card index 0.</p>
        ena_srd_specification: <p>Configures ENA Express for the network interface that this action attaches to the instance.</p>
        ena_queue_count: <p>The number of ENA queues to be created with the instance.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        network_interface_id: <p>The ID of the network interface.</p>
        instance_id: <p>The ID of the instance.</p>
        device_index: <p>The index of the device for the network interface attachment.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To attach a network interface to an instance
        This example attaches the specified network interface to the specified instance.

        >>> await client.attach_network_interface(network_interface_id='eni-e5aa89a3', instance_id='i-1234567890abcdef0', device_index=1)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.attach_network_interface_request.AttachNetworkInterfaceRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.attach_network_interface_result.AttachNetworkInterfaceResult"
    ]:
        import capo_ec2._operations.amazon_ec2.attach_network_interface

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.attach_network_interface.async_attach_network_interface(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AttachNetworkInterface")
    )
    input_: capo_ec2.types.attach_network_interface_request.AttachNetworkInterfaceRequest = {}
    if network_card_index is not None:
        input_["network_card_index"] = network_card_index
    if ena_srd_specification is not None:
        input_["ena_srd_specification"] = ena_srd_specification
    if ena_queue_count is not None:
        input_["ena_queue_count"] = ena_queue_count
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if network_interface_id is not None:
        input_["network_interface_id"] = network_interface_id
    if instance_id is not None:
        input_["instance_id"] = instance_id
    if device_index is not None:
        input_["device_index"] = device_index

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