简体   繁体   English

将ebs附加到ec2实例上

[英]attach ebs on ec2 instance create

I am trying to create and attach an EBS volume on instance creation but I am getting error of no option :ebs , I am able to do this from AWS console so there should be some way with which I can create instance using a volume as disk 我正在尝试在实例创建时创建并附加一个EBS卷,但是遇到了no option:ebs的错误,我能够从AWS控制台执行此操作,因此应该有某种方法可以使用卷作为磁盘来创建实例

instance = ec2.instances.create(:image_id => ami-aa***,
  :key_name => ec2.key_pairs["Dev-node"].name,
  :ebs => {
    :volume_size => 20, #size in GBs
    :delete_on_termination => true
  },
  :instance_type => 't1.micro')

I believe you need to pass the :block_device_mapping key, which should be an Array of hashes as outlined here , eg: 我相信您需要传递:block_device_mapping密钥,该密钥应该是此处概述的哈希数组,例如:

instance = ec2.instances.create(
  :image_id => "ami-aa***",
  :key_name => ec2.key_pairs["Dev-node"].name,
  :block_device_mapping => [
    {
      "DeviceName" => "/dev/sdf",
      "Ebs.VolumeSize" => 20,
      "Ebs.DeleteOnTermination" => true
    }
  ],
  :instance_type => 't1.micro'
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM