如何枚举正在运行的ec2实例并使用ruby将它们加载到数据库中? [英] How to enumerate running ec2 instances and load them into a database using ruby?
本文介绍了如何枚举正在运行的ec2实例并使用ruby将它们加载到数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用aws-sdk gem,我不知道如何列出所有正在运行的ec2实例并将其加载到数据库中.
I'm using aws-sdk gem, I can't figure how to list all the running ec2 instances and load them to a database.
我需要一种方法来做到这一点.
I need an approach on how to do it.
推荐答案
以上答案将返回所有实例,而不仅仅是运行中的实例.您可以使用过滤器仅获取正在运行的实例:
The answer above will return all instances, not just running instances. You can use a filter to get only running instances:
ec2 = AWS::EC2.new
ec2.instances.filter('instance-state-name', 'running')
这篇关于如何枚举正在运行的ec2实例并使用ruby将它们加载到数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文