create_key_pair
async
¶
create_key_pair(
*,
config_overrides: Optional[AsyncEC2ClientConfig] = None,
key_name: Optional[String] = None,
key_type: Optional[KeyType] = None,
tag_specifications: Optional[TagSpecificationList] = None,
key_format: Optional[KeyFormat] = None,
dry_run: Optional[Boolean] = None,
) -> KeyPair
Creates an ED25519 or 2048-bit RSA key pair with the specified name and in the specified format. Amazon EC2 stores the public key and displays the private key for you to save to a file. The private key is returned as an unencrypted PEM encoded PKCS#1 private key or an unencrypted PPK formatted private key for use with PuTTY. If a key with the specified name already exists, Amazon EC2 returns an error.
The key pair returned to you is available only in the Amazon Web Services Region in which you create it. If you prefer, you can create your own key pair using a third-party tool and upload it to any Region using ImportKeyPair.
You can have up to 5,000 key pairs per Amazon Web Services Region.
For more information, see Amazon EC2 key pairs in the Amazon EC2 User Guide.
Parameters:
-
key_name(Optional[String], default:None) –A unique name for the key pair.
Constraints: Up to 255 ASCII characters
-
key_type(Optional[KeyType], default:None) –The type of key pair. Note that ED25519 keys are not supported for Windows instances.
Default:
rsa -
tag_specifications(Optional[TagSpecificationList], default:None) –The tags to apply to the new key pair.
-
key_format(Optional[KeyFormat], default:None) –The format of the key pair.
Default:
pem -
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 isUnauthorizedOperation.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create a key pair This example creates a key pair named my-key-pair.
Source code in docs_src/capo_ec2/_services/async_ec2.py
9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 | |