并行启动多个 EC2 实例

Vam*_*ame 5 amazon-ec2 amazon-web-services

我想并行启动多台 EC2 机器。到目前为止,我一直在使用 boto 和 Fabric,但串行执行需要很长时间才能一一启动和配置它们。有没有其他解决方案可以做到这一点?

chr*_*ris 3

亚马逊命令行工具支持实例数量参数。

aws ec2 run-instances help
   --count (string)
      Number of instances to launch. If a single number is provided, it is
      assumed  to  be the minimum to launch (defaults to 1). If a range is
      provided in the form min:max then the first number is interpreted as
      the  minimum  number of instances to launch and the second is inter-
      preted as the maximum number of instances to launch.
Run Code Online (Sandbox Code Playgroud)

如果您运行的是旧版 CLI:

ec2-run-instances
 -n, --instance-count MIN[-MAX]
      The number of instances to attempt to launch. May be specified as a
      single integer or as a range (min-max). This specifies the minimum
      and maximum number of instances to attempt to launch. If a single
      integer is specified min and max are both set to that value.
Run Code Online (Sandbox Code Playgroud)

更新:根据 boto ec2 文档,您可以将 min_count 和 max_count 参数传递给 run_instances 命令,这也可以让您并行启动多个实例。