我对两个 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 运行良好,但我看不出有什么区别。
有人可以告诉我向 EC2 实例添加 EBS 卷的哪种方法更好吗?这两种方法有什么区别?
最佳答案
使用 BlockDeviceMappings,您不仅可以挂载 ebs 临时存储。 卷只是 ebs 卷,并提供更好的选项(例如选择 AZ,或者如果要使用 PIOP 则指定 IOP)。 如果您想要的只是简单的 ebs 卷,那么没有什么区别。
关于amazon-web-services - aws CloudFormation AWS::EC2::Instance BlockDeviceMappings 和卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15391718/