简体   繁体   中英

how to stop Amazon Aws EC2 instance?

I'm trying to write a script to stop several instances in our test environment on Friday and have them start back on Monday, to save little cost.

Is there a way to stop instances by IP addresses (and not by instance ID), or some other way I don't know about? (The reason being that instance ID's may change if an instance had to be deleted and recreated.)

This is a zero code solution:

Put your instances into autoscale groups and add a shutdown and startup schedule on the autoscale group. This can be done in the AWS console.

This can also be automated using the AWS CLI.

Use EC2 Tags to give your instances key/value tag pairs, then write a script using Boto which searches for instances with the right tags, and then terminates them.

You could also use Boto to list instances matching the specific IP address, and terminate them that way.

But... IP addresses are dynamically assigned (unless you are using Elastic IPs). So why not make a note of the instance IDs when launching the instances, instead of the IP address?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM