instance#

Functions for interacting with an instance based on its ID

async idem_aws.exec.aws.ec2.instance.bootstrap(hub, ctx, instance_id, *, username: str = None, host: str = None, port: int = 22, ssh_public_key: str = None, ssh_private_key: str = None, availability_zone: str = None, heist_manager: str, artifact_version: str = None, tunnel_plugin: str = 'asyncssh', auto_configure: bool = False, verify: bool = True, **kwargs)[source]#

Connect to the instance with an ssh keypair and call heist to bootstrap it.

If an ssh keypair is not provided one will be created.

Parameters:
  • instance_id – An AWS EC2 Instance ID.

  • username (str, Optional) – The instance OS username to use in the connection, Defaults to ec2-user.

  • host (str, Optional) – The public ip address or dns name of the instance. Defaults to autodetect.

  • port (int, Optional) – The port to connect to on the host. Defaults to 22.

  • ssh_public_key (str, Optional) – A public ssh key or path to send to the instance.

  • ssh_private_key (str, Optional) – A private ssh key or path to send to the instance.

  • availability_zone (str, Optional) – The Availability Zone in which the EC2 instance was launched.

  • heist_manager (str, Required) – The heist manager to use to bootstrap the instance (I.E. salt.minion).

  • artifact_version (str, Optional) – The version of the heist_manager’s artifact to upload to the instance, Defaults to latest.

  • tunnel_plugin (str, Optional) – The heist tunnel plugin to use to ssh into the instance. Defaults to asyncssh.

  • auto_configure (bool, Optional) – automatically apply internet_gateway/subnet/vpc/route_table changes needed to SSH into an instance.

  • verify (bool, Optional) – If set to True, then verify that the instance is prepared for ssh connections.

  • kwargs – All extra kwargs are used in asyncssh.SSHClientConnectionOptions.

Returns:

True|False, “comment”: A message Tuple, “ret”: Dict}

Return type:

{“result”

Examples

idem exec aws.ec2.instance.bootstrap <instance_id> heist_manager="salt.minion"
async idem_aws.exec.aws.ec2.instance.verify_ssh(hub, ctx, instance_id: str, auto_configure: bool = False)[source]#

Verify that an instance meets all the requirements for SSH connection

Parameters:
  • instance_id (str) – An AWS EC2 Instance ID.

  • auto_configure (bool, Optional) – Automatically apply internet_gateway/subnet/vpc/route_table changes needed to SSH into an instance.

Returns:

True|False, “comment”: A message Tuple, “ret”: Dict}

Return type:

{“result”

Examples

$ idem exec aws.ec2.instance.verify_ssh <instance_id> auto_configure=True
async idem_aws.exec.aws.ec2.instance.connect(hub, ctx, instance_id: str, *, username: str = None, host: str = None, port: int = 22, tunnel_plugin: str = 'asyncssh', ssh_public_key: str, private_key_file: str, availability_zone: str = None, **kwargs)[source]#

Attempt connection with SSH to the instance with the given parameters.

If no host or username is specified, then make reasonable guesses and return the target configuration that was successful

Parameters:
  • instance_id (str) – An AWS EC2 Instance ID.

  • username (str, Optional) – The instance OS username to use in the connection, Defaults to ec2-user.

  • host (str, Optional) – The public ip address or dns name of the instance. Defaults to autodetect.

  • port (int, Optional) – The port to connect to on the host. Defaults to 22.

  • ssh_public_key (str, Optional) – A public ssh key or path to send to the instance.

  • private_key_file (str, Optional) – The path to a private ssh key file.

  • availability_zone (str, Optional) – The Availability Zone in which the EC2 instance was launched.

  • tunnel_plugin (str, Optional) – The heist tunnel plugin to use to ssh into the instance. Defaults to asyncssh.

  • kwargs – All extra kwargs are used in asyncssh.SSHClientConnectionOptions.

Returns:

True|False, “comment”: A message Tuple, “ret”: Dict}

Return type:

{“result”

Examples

idem exec aws.ec2.instance.connect <instance_id>
async idem_aws.exec.aws.ec2.instance.start(hub, ctx, instance_id: (<class 'str'>, 'alias=resource_id') = None)[source]#

Start the instance and wait for it to be running

async idem_aws.exec.aws.ec2.instance.stop(hub, ctx, instance_id: (<class 'str'>, 'alias=resource_id') = None)[source]#

Stop the instance and wait for it to be stopped.

async idem_aws.exec.aws.ec2.instance.get(hub, ctx, *, name=None, resource_id: str = None, filters: List = None) Dict[source]#
Parameters:
async idem_aws.exec.aws.ec2.instance.list_(hub, ctx, *, name: str = None, filters: List = None) Dict[source]#
Parameters: