Skip to content

import_key_pair async

import_key_pair(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
    key_name: Optional[String] = None,
    public_key_material: Optional[Blob] = None,
) -> ImportKeyPairResult

Imports the public key from an RSA or ED25519 key pair that you created using a third-party tool. You give Amazon Web Services only the public key. The private key is never transferred between you and Amazon Web Services.

For more information about the requirements for importing a key pair, see Create a key pair and import the public key to Amazon EC2 in the Amazon EC2 User Guide.

Parameters:

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the imported key pair.

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

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

    A unique name for the key pair.

  • public_key_material (Optional[Blob], default: None ) –

    The public key.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def import_key_pair(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    key_name: Optional["capo_ec2.types.string.String"] = None,
    public_key_material: Optional["capo_ec2.types.blob.Blob"] = None,
) -> "capo_ec2.types.import_key_pair_result.ImportKeyPairResult":
    """<p>Imports the public key from an RSA or ED25519 key pair that you created using a third-party tool. You give Amazon Web Services only the public key. The private key is never transferred between you and Amazon Web Services.</p> <p>For more information about the requirements for importing a key pair, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#how-to-generate-your-own-key-and-import-it-to-aws">Create a key pair and import the public key to Amazon EC2</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        tag_specifications: <p>The tags to apply to the imported key pair.</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>
        key_name: <p>A unique name for the key pair.</p>
        public_key_material: <p>The public key.</p>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.import_key_pair_request.ImportKeyPairRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.import_key_pair_result.ImportKeyPairResult"
    ]:
        import capo_ec2._operations.amazon_ec2.import_key_pair

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ImportKeyPair")
    )
    input_: capo_ec2.types.import_key_pair_request.ImportKeyPairRequest = {}
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if key_name is not None:
        input_["key_name"] = key_name
    if public_key_material is not None:
        input_["public_key_material"] = public_key_material

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