Skip to content

import_host_key async

import_host_key(
    server_id: ServerId,
    host_key_body: HostKey,
    *,
    config_overrides: Optional[AsyncTransferClientConfig] = None,
    description: Optional[HostKeyDescription] = None,
    tags: Optional[Tags] = None,
    storage_type: Optional[HostKeyStorageType] = None,
    kms_key: Optional[KmsKey] = None,
) -> ImportHostKeyResponse

Adds a host key to the server that's specified by the ServerId parameter.

Parameters:

  • server_id (ServerId) –

    The identifier of the server that contains the host key that you are importing.

  • host_key_body (HostKey) –

    The private key portion of an SSH key pair.

    Transfer Family accepts RSA, ECDSA, and ED25519 keys.

  • description (Optional[HostKeyDescription], default: None ) –

    The text description that identifies this host key.

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

    Key-value pairs that can be used to group and search for host keys.

  • storage_type (Optional[HostKeyStorageType], default: None ) –

    Specifies whether the host key is stored by Transfer Family (SERVICE_MANAGED) or in Secrets Manager (SECRETS_MANAGER). When you specify SECRETS_MANAGER, Transfer Family stores the private host key material in an Secrets Manager secret.

  • kms_key (Optional[KmsKey], default: None ) –

    The Amazon Resource Name (ARN) of the KMS key used to encrypt the Secrets Manager secret that stores the host key. If you specify a customer managed key, its key policy must allow the AWSServiceRoleForTransfer service-linked role to decrypt the secret. If you don't specify a value, Transfer Family uses the Amazon Web Services managed key for Secrets Manager.

Raises:

Source code in docs_src/capo_transfer/_services/async_transfer.py
async def import_host_key(
    self,
    server_id: "capo_transfer.types.server_id.ServerId",
    host_key_body: "capo_transfer.types.host_key.HostKey",
    *,
    config_overrides: Optional[AsyncTransferClientConfig] = None,
    description: Optional[
        "capo_transfer.types.host_key_description.HostKeyDescription"
    ] = None,
    tags: Optional["capo_transfer.types.tags.Tags"] = None,
    storage_type: Optional[
        "capo_transfer.types.host_key_storage_type.HostKeyStorageType"
    ] = None,
    kms_key: Optional["capo_transfer.types.kms_key.KmsKey"] = None,
) -> "capo_transfer.types.import_host_key_response.ImportHostKeyResponse":
    """<p>Adds a host key to the server that's specified by the <code>ServerId</code> parameter.</p>

    Args:
        server_id: <p>The identifier of the server that contains the host key that you are importing.</p>
        host_key_body: <p>The private key portion of an SSH key pair.</p> <p>Transfer Family accepts RSA, ECDSA, and ED25519 keys.</p>
        description: <p>The text description that identifies this host key.</p>
        tags: <p>Key-value pairs that can be used to group and search for host keys.</p>
        storage_type: <p>Specifies whether the host key is stored by Transfer Family (<code>SERVICE_MANAGED</code>) or in Secrets Manager (<code>SECRETS_MANAGER</code>). When you specify <code>SECRETS_MANAGER</code>, Transfer Family stores the private host key material in an Secrets Manager secret.</p>
        kms_key: <p>The Amazon Resource Name (ARN) of the KMS key used to encrypt the Secrets Manager secret that stores the host key. If you specify a customer managed key, its key policy must allow the <code>AWSServiceRoleForTransfer</code> service-linked role to decrypt the secret. If you don't specify a value, Transfer Family uses the Amazon Web Services managed key for Secrets Manager.</p>

    Raises:
        capo_transfer.errors.internal_service_error.InternalServiceError: <p>This exception is thrown when an error occurs in the Transfer Family service.</p>
        capo_transfer.errors.invalid_request_exception.InvalidRequestException: <p>This exception is thrown when the client submits a malformed request.</p>
        capo_transfer.errors.resource_exists_exception.ResourceExistsException: <p>The requested resource does not exist, or exists in a region other than the one specified for the command.</p>
        capo_transfer.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource is not found by the Amazon Web ServicesTransfer Family service.</p>
        capo_transfer.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request has failed because the Amazon Web ServicesTransfer Family service is not available.</p>
        capo_transfer.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_transfer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_transfer.types.import_host_key_request.ImportHostKeyRequest]",
    ) -> AsyncOperationResponse[
        "capo_transfer.types.import_host_key_response.ImportHostKeyResponse"
    ]:
        import capo_transfer._operations.transfer_service.import_host_key

        (
            output,
            http_response,
        ) = await capo_transfer._operations.transfer_service.import_host_key.async_import_host_key(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_transfer.types.import_host_key_request.ImportHostKeyRequest",
    ) -> dict[str, Any]:
        import capo_transfer.types.import_host_key_request

        return capo_transfer.types.import_host_key_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ImportHostKey", redact_input=_redact_input),
    )
    input_: capo_transfer.types.import_host_key_request.ImportHostKeyRequest = {
        "server_id": server_id,
        "host_key_body": host_key_body,
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if storage_type is not None:
        input_["storage_type"] = storage_type
    if kms_key is not None:
        input_["kms_key"] = kms_key

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