ReleaseEngineering/How To/Manage AWS slaves


To simplify management of AWS slaves you can use aws_manage_instances.py script. It can stop, start, restart instances; enable or disable automatic reboot and automatic shutdown.

Usage

usage: aws_manage_instances.py [-h] [-k SECRETS] [-r REGIONS] [-m COMMENTS]
                               [-n] [-q]
                               {stop,start,restart,enable,disable,status} host
                               [host ...]

positional arguments:
  {stop,start,restart,enable,disable,status}
                        action to be performed
  host                  hosts to be processed

optional arguments:
  -h, --help            show this help message and exit
  -k SECRETS, --secrets SECRETS
                        optional file where secrets can be found
  -r REGIONS, --region REGIONS
                        optional list of regions
  -m COMMENTS, --comments COMMENTS
                        reason to disable
  -n, --dry-run         Dry run mode
  -q, --quiet           Supress logging messages

Examples

Disable automatic reboots and start bld-linux64-ec2-001 (you may also want to disable it in slavealloc):

python aws_manage_instances.py disable bld-linux64-ec2-001
python aws_manage_instances.py start bld-linux64-ec2-001

Reboot it

python aws_manage_instances.py reboot bld-linux64-ec2-001

Secrets (credentials)

There a 2 ways to pass AWS credentials to properly authenicate yourself.

AWS_CREDENTIAL_FILE

The underlying library (boto) uses AWS_CREDENTIAL_FILE environment variable with path to file with your credentials in the following format:

AWSAccessKeyId=xxx
AWSSecretKey=xxx

To use it add the following command to your profile

export AWS_CREDENTIAL_FILE=~/.ec2/aws-credential-file.txt

-k secrets.json

Create a JSON file with your credentials and pass it via -k parameter. Example file:

{
    "aws_access_key_id": "xxx",
    "aws_secret_access_key": "xxx"
}