2 Answers
2
There is no single API to stop all the running instances. You need to get the list of running instance using the describe_instances
API. You can use the instance-state-name
filter to get only the running
instances. Once you have the result, you can extract the instance IDs, place them in an array and call the stop_instances
API as you did before.
1
Accepted Answer
There is also a Solution for stopping instances on a schedule if that is what you are working on. Instance Scheduler on AWS
Relevant questions
Do I get charged for stopped instances?
Accepted Answerasked 5 years agoAutoscaling with python
asked 5 months agoLambda function to automatically stop an instance
Accepted Answerasked 12 days agoStart & Stop of EC2 instance using tags in Lambda function
Accepted Answerasked 5 months agoUnable to stop an instance
asked 2 months agoAny way to specify the private IP when creating an instance?
asked 2 years agoHow do I configure an Amazon MQ instance that's in a VPC to invoke a Lambda function?
Accepted Answerasked 2 years agoStart-stop EC2 instance using email
asked 3 months agoHow do I rename a Lightsail instance
asked 4 months agoCan't connect to an RDS Instance from Lambda (different account tough)
asked 2 years ago
Thanks so much, will give this a go