• Print
  • Share
  • Dark

Auto Scaling Events in AWS

  • Updated on 30 Oct 2018
  • 1 minute to read
  • Contributors

If you have AWS autoscale groups (including EBS instances), you may notice that inactive instances aren't being removed from the Retrace's Servers page dynamically during a scale down event. The following steps will guide you through the process of creating a trigger that will automatically remove the instances (servers) from Retrace so that inactive servers don't stick around in the Retrace.

Create a new AWS Lambda Function

To create a new Lambda Function, you will want to select "Author from scratch". Here you will name the function, select the runtime (use Node.js 6.10 or later), and select a role to run the function.

Note: Lambda Functions are region-specific, so be sure to create the function(s) in the same region(s) where you deploy your application.

2018-07-19 13_52_29.png

Upload the Function Code to your Lambda Function

After you create your function, you will want to add the code that will programmatically remove the servers when a scale down event occurs.

Download the index.zip file from our Github page and then upload the zip into your function.

Then under Code Entry Type select "Upload a .Zip file" 2018-07-19 15_25_14-Lambda Management Console.png

Add the Stackify API Key as an Environment Variable

2018-07-19 15_27_04-Lambda Management Console.png

Key Value
Stackify_ApiKey YOUR_API_KEY

Configure a CloudWatch Events Trigger

The next step is to create the trigger that will define when the function runs. To create the trigger, select CloudWatch Events and navigate to the "Configure triggers" section.

2018-07-19 15_42_05-Lambda Management Console.png

Here you will create and name a new rule, assign the Rule type as "Event pattern", select the "Instance launch and terminate" event, and use the "EC2 Instance Terminate Successful" event type.

2018-07-20 09_54_28-Lambda Management Console.png

Once configuration is complete, add the event and save your Lambda function.

Now every time an instance is terminated, the server instance will automatically removed from the Retrace Servers page.