Reputation: 10874
I have two servers (with my app on it) already running.. created from Ubuntu AMI. While using auto-scaling it starts new instances using an AMI.
Can I use auto-scaling to ONLY stop instance (not terminate; so that I don’t need an AMI when starting server in future); and later start instance (old instance which I had stopped) whenever CPU increases above x% !
If not auto-scaling; I am ok with any other solution also. I can stop the instance with Cloudwatch, but how do I restart it?
Upvotes: 3
Views: 1979
Reputation: 200607
It can't be done with AutoScaling. You could disable AutoScaling and have CloudWatch trigger some Lambda functions to start/stop your instances.
Upvotes: 0
Reputation: 78663
I would think you can do this with the following:
See the Scaling ECS article which is similar and Invoking Lambda from SNS.
Upvotes: 7
Reputation: 36073
Stopping an instance cannot currently be done using AutoScaling. AutoScaling can only launch new instances and terminate instances based on CloudWatch alerts, etc.
To do what you want, you'll need to stop using AutoScaling and use another "worker" EC2 instance to replace AutoScaling. That "worker" instance need to be running 24/7 and it will monitor the CPU of your other EC2 instances and start and stop them appropriately.
Upvotes: 1