Amazon Web Services Amazon Web Services: EC2 - Instances

Summary

This module contains actions for viewing & managing EC2 instances.

Actions

aws.ec2.instances.

get_all

Get all instances.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • vpc_id: the VPC ID to look in (defaults to all VPCs for the supplied region)

Output

A list of Instance dictionaries.

Example
1
2
3
4
5
- aws.ec2.instances.get_all:
    region_name: eu-west-2
  load:
    aws_client: aws_secrets
  save: all_instances

aws.ec2.instances.

get_by_id

Get an instance with a specific instance ID.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • instance_id: the instance ID to search for

Output

A single Instance dictionary.

Example
1
2
3
4
5
6
- aws.ec2.instances.get_by_id:
    region_name: eu-west-2
    instance_id: i-0e88060c12d5d7e71
  load:
    aws_client: aws_secrets
  save: instance

aws.ec2.instances.

get_by_name

Get instances with a specific name.

Minimum Plugin Version: 2.0.0

Instance Naming

Instances don't have a name attribute, so this action searches for the Name tag instead.

This tag is set automatically when you name an instance in the AWS console.

Unlike security groups, multiple instances can exist with the same name.

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • name: the instance name to search for

  • vpc_id: the VPC ID to look in (defaults to all VPCs for the supplied region)

Output

A list of Instance dictionaries.

Example
1
2
3
4
5
6
- aws.ec2.instances.get_by_name:
    region_name: eu-west-2
    name: Ubuntu Server
  load:
    aws_client: aws_secrets
  save: ubuntu_server_instances

aws.ec2.instances.

get_running

Get running instances.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • vpc_id: the VPC ID to look in (defaults to all VPCs for the supplied region)

Output

A list of Instance dictionaries.

Example
1
2
3
4
5
- aws.ec2.instances.get_running:
    region_name: eu-west-2
  load:
    aws_client: aws_secrets
  save: running_instances

aws.ec2.instances.

get_stopped

Get stopped instances.

This includes all hibernating instances.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • vpc_id: the VPC ID to look in (defaults to all VPCs for the supplied region)

Output

A list of Instance dictionaries.

Example
1
2
3
4
5
- aws.ec2.instances.get_stopped:
    region_name: eu-west-2
  load:
    aws_client: aws_secrets
  save: stopped_instances

aws.ec2.instances.

get_untagged

Get untagged instances.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • vpc_id: the VPC ID to look in (defaults to all VPCs for the supplied region)

Output

A list of Instance dictionaries.

Example
1
2
3
4
5
- aws.ec2.instances.get_untagged:
    region_name: eu-west-2
  load:
    aws_client: aws_secrets
  save: untagged_instances

aws.ec2.instances.

input_table

Display a list of instances in a table, & allow the task operator to make a selection.

The table will have the following columns:

  • Name
  • ID
  • State
  • Public DNS Name
  • Private DNS Name
  • VPC ID

Minimum Plugin Version: 2.0.0

Input
  • text: the title of the table

  • instances: a list of Instance dictionaries to display in the table

  • minimum: The minimum number of acceptable selections

  • maximum: The maximum number of acceptable selections

Output

A list of Instance dictionaries.

Tip
  • If neither a minimum or maximum is provided, the task operator will be able to submit 0 selections.

  • If minimum or maximum are provided, the operation will repeat until a valid number of selections is made.

Example

Finding instances with get_all, saving them as groups, & waiting for a single selection:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
- aws.ec2.instances.get_all:
    region_name: eu-west-2
  load:
    aws_client: aws_secrets
  save: instances

- aws.ec2.instances.input_table:
    text: Choose an instance
    minimum: 1
    maximum: 1
  load:
    instances: instances
  save: selected_instance

aws.ec2.instances.

output_table

Display a list of instances in a table.

The table will have the following columns:

  • Name
  • ID
  • State
  • Public DNS Name
  • Private DNS Name
  • VPC ID

Minimum Plugin Version: 2.0.0

Input
  • text: the title of the table

  • groups: a single or list of Instance dictionaries

Output

Nothing is outputted by this action.

Single Instance

Finding an instance with get_by_id, saving it as instance, & displaying it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
- aws.ec2.instances.get_by_id:
    region_name: eu-west-2
    instance_id: i-0e88060c12d5d7e71
  load:
    aws_client: aws_secrets
  save: instance

- aws.ec2.instances.output_table:
    text: Instance i-0e88060c12d5d7e71
  load:
    instances: instance
Multiple Instances

Finding all instances with get_all, saving them as instances, & displaying them:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- aws.ec2.instances.get_all:
    region_name: eu-west-2
  load:
    aws_client: aws_secrets
  save: instances

- aws.ec2.instances.output_table:
    text: All Instances
  load:
    instances: instances

aws.ec2.instances.

start

Start an instance.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • instance_id: the ID of the instance to start

Output

Nothing is outputted by this action.

Example
1
2
3
4
5
- aws.ec2.instances.start:
    region_name: eu-west-2
    instance_id: i-0e88060c12d5d7e71
  load:
    aws_client: aws_secrets

aws.ec2.instances.

stop

Stop an instance.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • instance_id: the ID of the instance to stop

Output

Nothing is outputted by this action.

Example
1
2
3
4
5
- aws.ec2.instances.stop:
    region_name: eu-west-2
    instance_id: i-0e88060c12d5d7e71
  load:
    aws_client: aws_secrets

aws.ec2.instances.

terminate

Terminate an instance.

Minimum Plugin Version: 2.0.0

Input
  • aws_client: an AWSClient dictionary

  • region_name: the EC2 region name

  • instance_id: the ID of the instance to terminate

Output

Nothing is outputted by this action.

Example
1
2
3
4
5
- aws.ec2.instances.terminate:
    region_name: eu-west-2
    instance_id: i-0e88060c12d5d7e71
  load:
    aws_client: aws_secrets