Table of Contents
A low-level client representing AWS EC2 Instance Connect:
client = session.create_client('ec2-instance-connect')
These are the available methods:
Check if an operation can be paginated.
Generate a presigned url given a client, its method, and arguments
The presigned url
Create a paginator for an operation.
Returns an object that can wait for some condition.
Pushes an SSH public key to a particular OS user on a given EC2 instance for 60 seconds.
See also: AWS API Documentation
Request Syntax
response = client.send_ssh_public_key(
InstanceId='string',
InstanceOSUser='string',
SSHPublicKey='string',
AvailabilityZone='string'
)
[REQUIRED]
The EC2 instance you wish to publish the SSH key to.
[REQUIRED]
The OS user on the EC2 instance whom the key may be used to authenticate as.
[REQUIRED]
The public key to be published to the instance. To use it after publication you must have the matching private key.
[REQUIRED]
The availability zone the EC2 instance was launched in.
dict
Response Syntax
{
'RequestId': 'string',
'Success': True|False
}
Response Structure
(dict) --
RequestId (string) --
The request ID as logged by EC2 Connect. Please provide this when contacting AWS Support.
Success (boolean) --
Indicates request success.
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:
Indicates that either your AWS credentials are invalid or you do not have access to the EC2 instance.
Example
try:
...
except client.exceptions.AuthException 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) --
Indicates that either your AWS credentials are invalid or you do not have access to the EC2 instance.
Indicates that the instance requested was not found in the given zone. Check that you have provided a valid instance ID and the correct zone.
Example
try:
...
except client.exceptions.EC2InstanceNotFoundException 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) --
Indicates that the instance requested was not found in the given zone. Check that you have provided a valid instance ID and the correct zone.
Indicates that you provided bad input. Ensure you have a valid instance ID, the correct zone, and a valid SSH public key.
Example
try:
...
except client.exceptions.InvalidArgsException 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) --
Indicates that you provided bad input. Ensure you have a valid instance ID, the correct zone, and a valid SSH public key.
Indicates that the service encountered an error. Follow the message's instructions and try again.
Example
try:
...
except client.exceptions.ServiceException 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) --
Indicates that the service encountered an error. Follow the message's instructions and try again.
Indicates you have been making requests too frequently and have been throttled. Wait for a while and try again. If higher call volume is warranted contact AWS Support.
Example
try:
...
except client.exceptions.ThrottlingException 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) --
Indicates you have been making requests too frequently and have been throttled. Wait for a while and try again. If higher call volume is warranted contact AWS Support.
The available paginators are: