Table of Contents
EC2InstanceConnect.
Client
¶A low-level client representing AWS 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.
client = session.create_client('ec2-instance-connect')
These are the available methods:
can_paginate
(operation_name)¶Check if an operation can be paginated.
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")
.
True
if the operation can be paginated,
False
otherwise.
get_paginator
(operation_name)¶Create a paginator for an operation.
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")
.
OperationNotPageableError – Raised if the operation is not
pageable. You can use the client.can_paginate
method to
check if an operation is pageable.
L{botocore.paginate.Paginator}
A paginator object.
get_waiter
(waiter_name)¶Returns an object that can wait for some condition.
waiter_name (str) – The name of the waiter to get. See the waiters section of the service docs for a list of available waiters.
The specified waiter object.
botocore.waiter.Waiter
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'
)
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 .
dict
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.SerialConsoleAccessDisabledException
EC2InstanceConnect.Client.exceptions.EC2InstanceNotFoundException
EC2InstanceConnect.Client.exceptions.EC2InstanceTypeInvalidException
EC2InstanceConnect.Client.exceptions.SerialConsoleSessionLimitExceededException
EC2InstanceConnect.Client.exceptions.SerialConsoleSessionUnavailableException
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'
)
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) –
[REQUIRED]
The Availability Zone in which the EC2 instance was launched.
dict
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
Client exceptions are available on a client instance via the exceptions
property. For more detailed instructions and examples on the exact usage of client exceptions, see the error handling user guide.
The available client exceptions are:
EC2InstanceConnect.Client.exceptions.EC2InstanceNotFoundException
EC2InstanceConnect.Client.exceptions.EC2InstanceTypeInvalidException
EC2InstanceConnect.Client.exceptions.SerialConsoleAccessDisabledException
EC2InstanceConnect.Client.exceptions.SerialConsoleSessionLimitExceededException
EC2InstanceConnect.Client.exceptions.SerialConsoleSessionUnavailableException
EC2InstanceConnect.Client.exceptions.
AuthException
¶Either your AWS credentials are not valid or you do not have access to the EC2 instance.
Example
try:
...
except client.exceptions.AuthException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
Either your AWS credentials are not valid or you do not have access to the EC2 instance.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
EC2InstanceNotFoundException
¶The specified instance was not found.
Example
try:
...
except client.exceptions.EC2InstanceNotFoundException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
The specified instance was not found.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
EC2InstanceTypeInvalidException
¶The instance type is not supported for connecting via the serial console. Only Nitro instance types are currently supported.
Example
try:
...
except client.exceptions.EC2InstanceTypeInvalidException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
The instance type is not supported for connecting via the serial console. Only Nitro instance types are currently supported.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
InvalidArgsException
¶One of the parameters is not valid.
Example
try:
...
except client.exceptions.InvalidArgsException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
One of the parameters is not valid.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
SerialConsoleAccessDisabledException
¶Your account is not authorized to use the EC2 Serial Console. To authorize your account, run the EnableSerialConsoleAccess API. For more information, see EnableSerialConsoleAccess in the Amazon EC2 API Reference .
Example
try:
...
except client.exceptions.SerialConsoleAccessDisabledException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
Your account is not authorized to use the EC2 Serial Console. To authorize your account, run the EnableSerialConsoleAccess API. For more information, see EnableSerialConsoleAccess in the Amazon EC2 API Reference .
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
SerialConsoleSessionLimitExceededException
¶The instance currently has 1 active serial console session. Only 1 session is supported at a time.
Example
try:
...
except client.exceptions.SerialConsoleSessionLimitExceededException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
The instance currently has 1 active serial console session. Only 1 session is supported at a time.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
Unable to start a serial console session. Please try again.
Example
try:
...
except client.exceptions.SerialConsoleSessionUnavailableException as e:
print(e.response)
The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
Unable to start a serial console session. Please try again.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
ServiceException
¶The service encountered an error. Follow the instructions in the error message and try again.
Example
try:
...
except client.exceptions.ServiceException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
The service encountered an error. Follow the instructions in the error message and try again.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
EC2InstanceConnect.Client.exceptions.
ThrottlingException
¶The requests were made too frequently and have been throttled. Wait a while and try again. To increase the limit on your request frequency, contact AWS Support.
Example
try:
...
except client.exceptions.ThrottlingException as e:
print(e.response)
response
¶The parsed error response. All exceptions have a top level Error
key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.
Syntax
{
'Message': 'string',
'Error': {
'Code': 'string',
'Message': 'string'
}
}
Structure
(dict) –
The requests were made too frequently and have been throttled. Wait a while and try again. To increase the limit on your request frequency, contact AWS Support.
Message (string) –
Error (dict) – Normalized access to common exception attributes.
Code (string) – An identifier specifying the exception type.
Message (string) – A descriptive message explaining why the exception occured.
The available paginators are: