通过HTML/Python/Bash Scrip停止awsec2实例

2024-03-29 13:39:31 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有什么方法可以通过HTML在电子邮件中发送一个按钮/超链接,从而触发Python/Bash脚本来停止正在运行的EC2实例?在

我基本上会检查所有正在运行的实例,通过Fabric->;SSH检查它们的正常运行时间,然后在正常运行时间超过指定限制时发送一封邮件。在

如果无法通过脚本实现,那么每个触发其停止的实例是否都有一个特定的超链接?在

PS:我了解Amazon CloudWatch,但我正在寻找替代方案,因为我必须通过CloudWatch为每个实例手动创建一个警报。在

PS-2:我不需要全部代码。在这方面的任何帮助都将不胜感激。
示例:可以使用哪些框架?等等


Tags: 实例方法gt脚本bash电子邮件html时间
1条回答
网友
1楼 · 发布于 2024-03-29 13:39:31

对于处理amazon实例,您可能希望使用boto,它提供了大多数常见的所需功能。阅读文档非常重要,因为可能会丢失数据。考虑启动here。在

要计算实例运行了多长时间,可以使用^{}。在

要停止实例,可以使用^{}

Stops an Amazon EBS-backed instance. Each time you transition an instance from stopped to started, Amazon EC2 charges a full instance hour, even if transitions happen multiple times within a single hour.

You can't start or stop Spot Instances. (more in link...)

要终止实例,请使用^{}

Shuts down one or more instances. This operation is idempotent; if you terminate an instance more than once, each call succeeds.

By default, Amazon EC2 deletes all EBS volumes that were attached when the instance launched. Volumes attached after instance launch continue running.

相关问题 更多 >