【问题标题】:aws CloudFormation AWS::EC2::Instance BlockDeviceMappings and Volumesaws CloudFormation AWS::EC2::Instance BlockDeviceMappings 和 Volumes
【发布时间】:2013-03-01 18:22:50
【问题描述】:

我对两个 AWS::EC2::Instance 属性感到困惑: BlockDeviceMappings 和 Volumes。

我已经阅读了很多次文档,但仍然没有真正理解其中的区别。

这是我的模板:

 {
 "AWSTemplateFormatVersion" : "2010-09-09",

 "Description" : "kappoowTest",

 "Mappings" : {
     "AmazonLinuxAMI" : {
         "eu-west-1" :
             { "AMI" : "ami-d8f9f1ac" },
         "us-west-1" :
             { "AMI" : "ami-b63210f3" }
     }
 },

 "Resources" : {
     "SomeInstance" :{
         "Type" : "AWS::EC2::Instance",
         "Properties" : {
             "AvailabilityZone" : "eu-west-1a",
             "BlockDeviceMappings" : [
                 {
                     "DeviceName" : "/dev/sdc",
                     "Ebs" : { "VolumeSize" : "50" }
                 },
                 {
                     "DeviceName" : "/dev/sdd",
                     "Ebs" : { "VolumeSize" : "100" }
                 }
             ],
             "DisableApiTermination" : "true",
             "EbsOptimized" : "true",
             "ImageId" : { "Fn::FindInMap" : [ "AmazonLinuxAMI", { "Ref" : "AWS::Region" }, "AMI" ]},
             "InstanceType" : "m1.large",
             "KeyName" : "mongo_test",
             "Monitoring" : "true",
             "SecurityGroups" : [ "default" ],
             "Volumes" : [
                 { "VolumeId" : { "Ref" : "NewVolume" }, "Device" : "/dev/sdk" }
             ]
         }
     },

     "NewVolume" : {
         "Type" : "AWS::EC2::Volume",
         "Properties" : {
             "Size" : "100",
             "AvailabilityZone" : "eu-west-1a"
         }
     }
 }}

在这里我创建了 3 卷。 2 与

 "BlockDeviceMappings" : [
                 {
                     "DeviceName" : "/dev/sdc",
                     "Ebs" : { "VolumeSize" : "50" }
                 },
                 {
                     "DeviceName" : "/dev/sdd",
                     "Ebs" : { "VolumeSize" : "100" }
                 }
             ]

还有一个:

"Volumes" : [
    { "VolumeId" : 
          { "Ref" : "NewVolume" }, "Device" : "/dev/sdk" }
 ]

CloudFormation 运行良好,但我看不出有什么不同。

有人能告诉我哪种方法更好地将 EBS 卷添加到 EC2 实例,这两种方法有什么区别?

【问题讨论】:

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


    【解决方案1】:

    使用 BlockDeviceMappings,您不仅可以挂载 ebs,还可以挂载临时存储。 Volumes 只是 ebs 卷,并且提供了更好的选项(例如选择 AZ,或者如果您想使用 PIOP,则指定 IOP)。 如果您想要的只是简单的 ebs 卷,那么没有区别。

    【讨论】:

    • 我认为这已经改变了。块设备映射具有通过“Ebs”属性定义 iops 等的选项。虽然 AZ 将与 EC2 相同 - 因为它只能在同一个 AZ 中使用卷/ebs。
    猜你喜欢
    • 1970-01-01
    • 2014-01-01
    • 2019-10-23
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    • 2018-06-27
    • 1970-01-01
    相关资源
    最近更新 更多