Tagging instances is the first requirement to make our operator work. This action makes the instances visible to our codebase.

Configuring the AWS command-line interface tool is out of the scope for this documentation. If you don’t have this part already working – head up to the official documentation for the details.

The instances we’ll use for the operator need two tags to make them manageable:

  • resource-booking/managed - Used to mark the instance as managed by the operator.
  • resource-booking/application - The name of the resource to group the instances by.

Tagging using AWS CLI

The AWS command-line interface allows us to change our resources without wondering through the dashboard. We’ve exported the few of the parts that are responsible for the instance tagging and listing into our makefile to make this process a bit quicker.

List instances

Calling make list-instances will list our instances and also provide us information which ones have the managed and resource tags. We can use this to keep track of our resources and detect instances that need to be changed.

$ make list-instances

-------------------------------------------------
|               DescribeInstances               |
+----------------------+----------+-------------+
|       Instance       | Managed  |  Resource   |
+----------------------+----------+-------------+
|  i-0b1b591a931567907 |  true    |  analytics  |
|  i-0073357fb586b5a74 |  None    |  None       |
|  i-09bf70d1832a14871 |  true    |  web        |
|  i-0e7f363c3871a249f |  true    |  analytics  |
|  i-0bf4736484ecdfef5 |  true    |  web        |
+----------------------+----------+-------------+

Mark as managed

Marking the instances as managed makes them visible for our tool. The make mark-managed command expects two parameters:

  • instances - a space-separated instance IDs
  • enable - Wether to set the instances as managed. Values can be true or false.

An example usage can be:

make mark-managed instances="i-09bf70d1832a14871 i-0bf4736484ecdfef5" enable=true

Create resource tags

We can directly add resource tag to our instances, using make tag-instances. The command expects two parameters:

  • instances - a space-separated instance IDs
  • tag - The resource name

An example usage can be:

make tag-instances instances="i-09bf70d1832a14871 i-0bf4736484ecdfef5" tag=web

Tagging using the AWS dashboard interface

We can also use the AWS Dashboard to tag instances, but this is out of scope for this documentation. Head up to the official docs for more details.