aws CloudFormation AWS::EC2::Instance BlockDeviceMappings 和卷 [英] aws CloudFormation AWS::EC2::Instance BlockDeviceMappings and Volumes

查看:38
本文介绍了aws CloudFormation AWS::EC2::Instance BlockDeviceMappings 和卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对两个 AWS::EC2::Instance 属性有点困惑:BlockDeviceMappingsVolumes.

I am sort of confused about two AWS::EC2::Instance properties: BlockDeviceMappings and Volumes.

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

I have read documentation a number of times but still don't really understand the difference.

这是我的模板:

 {
 "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 与

Here I have created 3 volumes. 2 with

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

和另一个:

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

CloudFormation 运行良好,但我看不出区别.

CloudFormation ran fine, but I fail to see the difference.

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

Could someone tell me what which way is better of adding EBS volumes to EC2 instance and what is the difference between these two methods ?

推荐答案

使用 BlockDeviceMappings,您不仅可以挂载 ebs.Volumes 只是 ebs 卷,并且提供了更好的选项(比如选择 AZ,或者如果你想使用 PIOPs 指定 IOPs).如果您想要的只是简单的 ebs 卷,那么没有区别.

With BlockDeviceMappings you can mount ephemeral storage not only ebs. Volumes is only ebs volumes, and provides better options (like choosing the AZ, or specifying the IOPs if you want to use PIOPs). If all what you want is simple ebs volumes, then there is no difference.

这篇关于aws CloudFormation AWS::EC2::Instance BlockDeviceMappings 和卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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