Correct answer - "Create a custom metric in CloudWatch and make your instances send data to it
using PutMetricData. Create an alarm based on that metric" : RAM is not a metric that gets
automatically sent to CloudWatch and therefore you must create a custom metric for it, and
create an alarm on top of that for your ASG auto scaling policies.
"Create a custom alarm for your ASG and make your instances trigger the alarm using PutAlarmData
API" - this will not work as your instances must be aware of each other's RAM to know when the
average RAM would be too high and trigger an alarm.
"Enable detailed monitoring for EC2 and ASG" - By enabling detailed monitoring you reduce the
time metric data is sent to CloudWatch from 5 minutes to 1 minute but you still have to create
the alarms to customize what you need for RAM.
"Migrate your application to AWS Lambda" - Lambda is a good option for autoscaling but there is
no sense in rebuilding your application when it works and can take advantage of CloudWatch
features