EC2 Instance without any attached Volume?

∥☆過路亽.° 提交于 2019-12-12 03:36:25

问题


Is it Possible to have instances without any volume(root-device or attached volume)?
Lets say the instance_ids are [i-120cd3fe,i-23e46634]
Is it possible that any Instances are present without any attached volume in AWS?

    conn=get_ec2_connection(region=region)  
    instances = conn.get_only_instances(instance_ids=instance_ids)   
    volumes_list=[]
    for instance in instances:  
       dev_mappings = instance.block_device_mapping  
       for block_device in dev_mappings.keys():  
           volume_id = dev_mappings[block_device].volume_id
           volumes_list.append(volume_id)

    print volumes_list  

Output-Should be : [None]


回答1:


You can't have an instance without a root volume. So there will always be at least one volume listed in the block device mapping.

I'm wrong about that. It has been so long since I launched an instance store backed AMI that I kind of forgot they even existed. An instance store backed AMI does not describe its root volume in the block device mapping so if you have such an instance and have no EBS volumes attached the block device mapping would be empty.

For an EBS-based instance the block device mapping will always contain the root volume (at least) even for stopped instances UNLESS you have explicitly detached that volume from the instance.




回答2:


It's absolutely possible, at least if the instance isn't currently running.

Consider the common tactic used to rescue yourself from an instance that won't boot:

Stop instance.

Detach root volume, so you can attach it to a working instance and repair the problem.

Right about here, you should have an instance with no volumes, if the root EBS volume were the only volume that instance had.

Other speculations:

I can't confirm, but it's conceivable that instance-store instances, which use an ephemeral disk might also match this.

It seems possible that you could forcibly detach the root EBS volume from a running instance, leaving it in a volume-less state, thought it would crash pretty promptly.

Instances might also end up in this state, briefly, after termination, as their EBS volumes are detached and potentially deleted. (Terminated instances still seem to appear as instances for a short time after you terminate them).



来源:https://stackoverflow.com/questions/30620193/ec2-instance-without-any-attached-volume

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!