KBI 311483 AWS Use System Command Alert To Start EC2 Instance


Argent for AWS 5.1A-1610-A and later


Thursday, 1 December 2016


AWS CLI allows managing AWS resource through command line

When Argent for AWS Engine detects some abnormal condition, it is possible to fire System Command Alert, which in turn calls AWS CLI to do some management tasks

This KBI shows how to start a stopped EC2 instance

Other possible applications are also listed

Customer has to install AWS CLI first on Argent Console Main Engine or Alert Executor server

The MSI package can be found on


When Argent for AWS Engine sends the alerting request to Argent Console Engine, AWS object information is passed through following keywords:

AWS key Id
AWS secret key
AWS secret key
AWS region
EC2 instance Id
S3 bucket
S3 object
  • %AGVAR(“RDS”)
RDS internal name
Elastic Beanstalk application name
Elastic Beanstalk application environment name
DynamoDB table Id

One tricky issue in AWS CLI is that the credentials cannot be passed through command line arguments

To address this, a CMD file can be created so that credentials can be set as environment variables before calling AWS CLI

Next is to define the System Command Alert calling the CMD with correct arguments


The key Id, secret, region and EC2 instance are passed in as argument 1, 2, 3 and 4 respectively

With the System Command Alert defined corrected, it is simply a matter of using it with Rule EC2_INST_STATUS_STOPPED in a Relator

When an EC2 instance is found stopped, the System Command Alert should run the AWS CLI to start it

Other applications of same technology can be as follows:

  • Stop EC2 instance

  • aws.exe ec2 stop-instances -instance-ids %AGVAR(“INTERNAL”)

  • Terminate EC2 instance

  • aws.exe ec2 terminate-instances -instance-ids %AGVAR(“INTERNAL”)

  • Describe detail of EC2 instance

  • aws.exe ec2 describe-instances -instance-ids %AGVAR(“INTERNAL”)

  • Describe detail of S3 bucket

  • aws.exe s3 list s3:// %AGVAR(“BUCKET”)

  • Publish Alert detail to SNS topic

  • aws.exe sns publish –topic-arn arn:aws:sns:us-west-2:123456789012:my-topic –message “%AGLowDetail%”

Technical Background