EC2InstanceConnect ****************** Client ====== class EC2InstanceConnect.Client A low-level client representing AWS EC2 Instance Connect This is the *Amazon EC2 Instance Connect API Reference*. It provides descriptions, syntax, and usage examples for each of the actions for Amazon EC2 Instance Connect. Amazon EC2 Instance Connect enables system administrators to publish one-time use SSH public keys to EC2, providing users a simple and secure way to connect to their instances. To view the Amazon EC2 Instance Connect content in the *Amazon EC2 User Guide*, see Connect to your Linux instance using EC2 Instance Connect. For Amazon EC2 APIs, see the Amazon EC2 API Reference. import boto3 client = boto3.client('ec2-instance-connect') These are the available methods: * can_paginate * close * get_paginator * get_waiter * send_serial_console_ssh_public_key * send_ssh_public_key EC2InstanceConnect / Client / get_paginator get_paginator ************* EC2InstanceConnect.Client.get_paginator(operation_name) Create a paginator for an operation. Parameters: **operation_name** (*string*) -- The operation name. This is the same name as the method name on the client. For example, if the method name is "create_foo", and you'd normally invoke the operation as "client.create_foo(**kwargs)", if the "create_foo" operation can be paginated, you can use the call "client.get_paginator("create_foo")". Raises: **OperationNotPageableError** -- Raised if the operation is not pageable. You can use the "client.can_paginate" method to check if an operation is pageable. Return type: "botocore.paginate.Paginator" Returns: A paginator object. EC2InstanceConnect / Client / can_paginate can_paginate ************ EC2InstanceConnect.Client.can_paginate(operation_name) Check if an operation can be paginated. Parameters: **operation_name** (*string*) -- The operation name. This is the same name as the method name on the client. For example, if the method name is "create_foo", and you'd normally invoke the operation as "client.create_foo(**kwargs)", if the "create_foo" operation can be paginated, you can use the call "client.get_paginator("create_foo")". Returns: "True" if the operation can be paginated, "False" otherwise. EC2InstanceConnect / Client / send_ssh_public_key send_ssh_public_key ******************* EC2InstanceConnect.Client.send_ssh_public_key(**kwargs) Pushes an SSH public key to the specified EC2 instance for use by the specified user. The key remains for 60 seconds. For more information, see Connect to your Linux instance using EC2 Instance Connect in the *Amazon EC2 User Guide*. See also: AWS API Documentation **Request Syntax** response = client.send_ssh_public_key( InstanceId='string', InstanceOSUser='string', SSHPublicKey='string', AvailabilityZone='string' ) Parameters: * **InstanceId** (*string*) -- **[REQUIRED]** The ID of the EC2 instance. * **InstanceOSUser** (*string*) -- **[REQUIRED]** The OS user on the EC2 instance for whom the key can be used to authenticate. * **SSHPublicKey** (*string*) -- **[REQUIRED]** The public key material. To use the public key, you must have the matching private key. * **AvailabilityZone** (*string*) -- The Availability Zone in which the EC2 instance was launched. Return type: dict Returns: **Response Syntax** { 'RequestId': 'string', 'Success': True|False } **Response Structure** * *(dict) --* * **RequestId** *(string) --* The ID of the request. Please provide this ID when contacting AWS Support for assistance. * **Success** *(boolean) --* Is true if the request succeeds and an error otherwise. **Exceptions** * "EC2InstanceConnect.Client.exceptions.AuthException" * "EC2InstanceConnect.Client.exceptions.InvalidArgsException" * "EC2InstanceConnect.Client.exceptions.ServiceException" * "EC2InstanceConnect.Client.exceptions.ThrottlingException" * "EC2InstanceConnect.Client.exceptions.EC2InstanceNotFoundExcepti on" * "EC2InstanceConnect.Client.exceptions.EC2InstanceStateInvalidExc eption" * "EC2InstanceConnect.Client.exceptions.EC2InstanceUnavailableExce ption" **Examples** The following example pushes a sample SSH public key to the EC2 instance i-abcd1234 in AZ us-west-2b for use by the instance OS user ec2-user. response = client.send_ssh_public_key( # The zone where the instance was launched AvailabilityZone='us-west-2a', # The instance ID to publish the key to. InstanceId='i-abcd1234', # This should be the user you wish to be when ssh-ing to the instance (eg, ec2-user@[instance IP]) InstanceOSUser='ec2-user', # This should be in standard OpenSSH format (ssh-rsa [key body]) SSHPublicKey='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3FlHqj2eqCdrGHuA6dRjfZXQ4HX5lXEIRHaNbxEwE5Te7xNF7StwhrDtiV7IdT5fDqbRyGw/szPj3xGkNTVoElCZ2dDFb2qYZ1WLIpZwj/UhO9l2mgfjR56UojjQut5Jvn2KZ1OcyrNO0J83kCaJCV7JoVbXY79FBMUccYNY45zmv9+1FMCfY6i2jdIhwR6+yLk8oubL8lIPyq7X+6b9S0yKCkB7Peml1DvghlybpAIUrC9vofHt6XP4V1i0bImw1IlljQS+DUmULRFSccATDscCX9ajnj7Crhm0HAZC0tBPXpFdHkPwL3yzYo546SCS9LKEwz62ymxxbL9k7h09t', ) print(response) Expected Output: { # This request ID should be provided when contacting AWS Support. 'RequestId': 'abcd1234-abcd-1234-abcd-1234abcd1234', # Should be true if the service does not return an error response. 'Success': True, 'ResponseMetadata': { '...': '...', }, } EC2InstanceConnect / Client / get_waiter get_waiter ********** EC2InstanceConnect.Client.get_waiter(waiter_name) Returns an object that can wait for some condition. Parameters: **waiter_name** (*str*) -- The name of the waiter to get. See the waiters section of the service docs for a list of available waiters. Returns: The specified waiter object. Return type: "botocore.waiter.Waiter" EC2InstanceConnect / Client / send_serial_console_ssh_public_key send_serial_console_ssh_public_key ********************************** EC2InstanceConnect.Client.send_serial_console_ssh_public_key(**kwargs) Pushes an SSH public key to the specified EC2 instance. The key remains for 60 seconds, which gives you 60 seconds to establish a serial console connection to the instance using SSH. For more information, see EC2 Serial Console in the *Amazon EC2 User Guide*. See also: AWS API Documentation **Request Syntax** response = client.send_serial_console_ssh_public_key( InstanceId='string', SerialPort=123, SSHPublicKey='string' ) Parameters: * **InstanceId** (*string*) -- **[REQUIRED]** The ID of the EC2 instance. * **SerialPort** (*integer*) -- The serial port of the EC2 instance. Currently only port 0 is supported. Default: 0 * **SSHPublicKey** (*string*) -- **[REQUIRED]** The public key material. To use the public key, you must have the matching private key. For information about the supported key formats and lengths, see Requirements for key pairs in the *Amazon EC2 User Guide*. Return type: dict Returns: **Response Syntax** { 'RequestId': 'string', 'Success': True|False } **Response Structure** * *(dict) --* * **RequestId** *(string) --* The ID of the request. Please provide this ID when contacting AWS Support for assistance. * **Success** *(boolean) --* Is true if the request succeeds and an error otherwise. **Exceptions** * "EC2InstanceConnect.Client.exceptions.AuthException" * "EC2InstanceConnect.Client.exceptions.SerialConsoleAccessDisable dException" * "EC2InstanceConnect.Client.exceptions.InvalidArgsException" * "EC2InstanceConnect.Client.exceptions.ServiceException" * "EC2InstanceConnect.Client.exceptions.ThrottlingException" * "EC2InstanceConnect.Client.exceptions.EC2InstanceNotFoundExcepti on" * "EC2InstanceConnect.Client.exceptions.EC2InstanceTypeInvalidExce ption" * "EC2InstanceConnect.Client.exceptions.SerialConsoleSessionLimitE xceededException" * "EC2InstanceConnect.Client.exceptions.SerialConsoleSessionUnavai lableException" * "EC2InstanceConnect.Client.exceptions.EC2InstanceStateInvalidExc eption" * "EC2InstanceConnect.Client.exceptions.EC2InstanceUnavailableExce ption" * "EC2InstanceConnect.Client.exceptions.SerialConsoleSessionUnsupp ortedException" EC2InstanceConnect / Client / close close ***** EC2InstanceConnect.Client.close() Closes underlying endpoint connections.