Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

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

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

Here is my template:

 {

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

         }

     }

 }}

Here I have created 3 volumes. 2 with

 "BlockDeviceMappings" : [

                 {

                     "DeviceName" : "/dev/sdc",

                     "Ebs" : { "VolumeSize" : "50" }

                 },

                 {

                     "DeviceName" : "/dev/sdd",

                     "Ebs" : { "VolumeSize" : "100" }

                 }

             ]

and another one with:

"Volumes" : [

    { "VolumeId" : 

          { "Ref" : "NewVolume" }, "Device" : "/dev/sdk" }

 ]

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

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?

1 Answer

0 votes
by (44.4k points)

You can mount ephemeral storage with BlockDeviceMappings, not just EBS. EBS volumes provide better options, where you can choose the availability zone and configure other options. For using simple EBS volumes, there is no difference between the methods.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories

...