如何在AWS Stack中添加多个EC2实例 [英] how to add multiple ec2 instances inside aws stack

查看:233
本文介绍了如何在AWS Stack中添加多个EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过门户或云形成创建一个AWS堆栈。但是我想在一个堆栈中添加多个EC2实例。我找不到足够的例子。我怎么找到一个?

I want to create an AWS stack through portal or through cloud formation. But I want to add multiple EC2 instances in one single stack. I am not finding enough examples. How can I find one ?

推荐答案

只需添加更多 AWS :: EC2 :: Instance 资源进入您的CloudFormation模板。

Just add more AWS::EC2::Instance resource into your CloudFormation template.

例如:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Ec2 block device mapping",
  "Resources": {
    "MyEC2Instance1": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": "ami-79fd7eee",
        "KeyName": "testkey1",
        "BlockDeviceMappings": [
          {
            "DeviceName": "/dev/sdm",
            "Ebs": {
              "VolumeType": "io1",
              "Iops": "200",
              "DeleteOnTermination": "false",
              "VolumeSize": "20"
            }
          },
          {
            "DeviceName": "/dev/sdk",
            "NoDevice": {
            }
          }
        ]
      }
    },
    "MyEC2Instance2": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": "ami-79fd7eee",
        "KeyName": "testkey2",
        "BlockDeviceMappings": [
          {
            "DeviceName": "/dev/sdm",
            "Ebs": {
              "VolumeType": "io1",
              "Iops": "200",
              "DeleteOnTermination": "false",
              "VolumeSize": "20"
            }
          },
          {
            "DeviceName": "/dev/sdk",
            "NoDevice": {
            }
          }
        ]
      }
    }
  }
}

这篇关于如何在AWS Stack中添加多个EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆