如何使用云模板添加存储?

时间:2019-05-16 05:16:35

标签: amazon-web-services amazon-ec2 amazon-cloudformation

我有一个CloudFormation模板来启动EC2实例。

Parameters:
  InstanceType:
    Type: String
    Description: Instance type for RStudio. Default is t2.micro.
    AllowedValues:
      - t2.micro
      - t2.small
      - t2.medium
      - t2.large
    ConstraintDescription: 'Valid instance type in the t2 family'
    Default: t2.micro
  ImageId:
    Type: 'AWS::EC2::Image::Id'
    Description: >-
      Amazon Linux Image ID. Default is for 2017.03.01 (HVM). N.B. 
    Default: ami-4fffc834

当我手动启动实例时,有一个添加存储的选项。默认值为8gb,而我想改为16gb。

我寻找了使用CloudFormation添加存储的语法。设置默认大小以外的其他卷的语法是什么?

1 个答案:

答案 0 :(得分:2)

您需要为此添加块设备映射...

 "BlockDeviceMappings": [
    {
      "DeviceName": "/dev/xvda",
      "Ebs": {
        "DeleteOnTermination": true,
        "VolumeType": "standard",
        "VolumeSize": 16
      }
    }
  ]

可以在此处找到工作示例...

https://github.com/shantanuo/cloudformation/blob/master/security.template2.txt