Skip to content

create_network_interface_permission

create_network_interface_permission(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    network_interface_id: Optional[NetworkInterfaceId] = None,
    aws_account_id: Optional[String] = None,
    aws_service: Optional[String] = None,
    permission: Optional[InterfacePermissionType] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateNetworkInterfacePermissionResult

Grants an Amazon Web Services-authorized account permission to attach the specified network interface to an instance in their account.

You can grant permission to a single Amazon Web Services account only, and only one account at a time.

Parameters:

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

    The ID of the network interface.

  • aws_account_id (Optional[String], default: None ) –

    The Amazon Web Services account ID.

  • aws_service (Optional[String], default: None ) –

    The Amazon Web Services service. Currently not supported.

  • permission (Optional[InterfacePermissionType], default: None ) –

    The type of permission to grant.

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

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def create_network_interface_permission(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    network_interface_id: Optional[
        "capo_ec2.types.network_interface_id.NetworkInterfaceId"
    ] = None,
    aws_account_id: Optional["capo_ec2.types.string.String"] = None,
    aws_service: Optional["capo_ec2.types.string.String"] = None,
    permission: Optional[
        "capo_ec2.types.interface_permission_type.InterfacePermissionType"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.create_network_interface_permission_result.CreateNetworkInterfacePermissionResult":
    """<p>Grants an Amazon Web Services-authorized account permission to attach the specified network interface to an instance in their account.</p> <p>You can grant permission to a single Amazon Web Services account only, and only one account at a time.</p>

    Args:
        network_interface_id: <p>The ID of the network interface.</p>
        aws_account_id: <p>The Amazon Web Services account ID.</p>
        aws_service: <p>The Amazon Web Services service. Currently not supported.</p>
        permission: <p>The type of permission to grant.</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>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_network_interface_permission_request.CreateNetworkInterfacePermissionRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_network_interface_permission_result.CreateNetworkInterfacePermissionResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_network_interface_permission

        output, http_response = (
            capo_ec2._operations.amazon_ec2.create_network_interface_permission.create_network_interface_permission(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateNetworkInterfacePermission")
    )
    input_: capo_ec2.types.create_network_interface_permission_request.CreateNetworkInterfacePermissionRequest = {}
    if network_interface_id is not None:
        input_["network_interface_id"] = network_interface_id
    if aws_account_id is not None:
        input_["aws_account_id"] = aws_account_id
    if aws_service is not None:
        input_["aws_service"] = aws_service
    if permission is not None:
        input_["permission"] = permission
    if dry_run is not None:
        input_["dry_run"] = dry_run

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