- 1 Minute to read
- Print
- DarkLight
- PDF
AWS Auto Scaling Events
- 1 Minute to read
- Print
- DarkLight
- PDF
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.
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"
Add the Stackify API Key as an Environment Variable
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.
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.
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.