AWS的.Net SDK与特定的EBS卷大小创建一个Amazon EC2实例 [英] AWS .Net SDK Create an Amazon EC2 instance with a specific EBS Volume Size

查看:281
本文介绍了AWS的.Net SDK与特定的EBS卷大小创建一个Amazon EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发用于创建和管理编程EC2实例的.NET Web应用程序。截至目前,当创建新的情况下,盘卷的尺寸是固定的:由图像(AMI)相信所定义。

我想创建一个新的实例时predefine磁盘卷的大小,这样我不需要事后运行调整大小操作。那可能吗?这将是最好的方法?

我有几个想法:


  1. 定义RunInstancesRequest对象上的音量大小。但我认为没有这样的选择。


  2. 创建AMI图像具有不同的磁盘大小副本,并使用一个请求新的EC2实例。可以这样做?


  3. 任何其他/更好的办法?


在的情况下,帮助,我附上code我目前使用要求新的实例:

  VAR launchRequest =新RunInstancesRequest()
    {
        ImageId = amiID,
        InstanceType =类型,
        MinCount = 1,
        MAXCOUNT = 1,
        SecurityGroupIds =组
    };
    VAR launchResponse = ec2Client.RunInstances(launchRequest);
    VAR实例= launchResponse.Reservation.Instances;
    变种将myInstance = instances.First();


解决方案

您需要设置的 VolumeSize EbsBlockDevice 的(整数GIB)值在 launchRequest BlockDeviceMappings 推出之前。

请记住,如果你指定一个快照,卷的大小必须等于或大于快照的大小。另外,如果您正在创建从快照的数量和不指定卷大小,默认为快照大小。

提示:要经常检查的布尔值 DeleteOnTermination 以及不要假设它有一个默认值的真正的根卷作为在AWS控制台。

你可以发现更多的信息上EbsBlockDevice性质这里

I am developing a .net web application that creates and manages ec2 instances programatically. As of now, when I create new instances, the size of the disk volume is fixed: defined by the image (AMI) I believe.

I would like to Predefine the size of the disk volume when creating a new instance so that I don't need to run a resize operation afterwards. Is that possible? Which would be the best approach?

I have a few ideas:

  1. Define the volume size on the RunInstancesRequest object. But I think there is no such option.

  2. Create a copy of the AMI image with a different disk size and use that one to request a new EC2 instance. Can this be done?

  3. Any other/better ways?

In case that helps, I attach the code I currently use to request new instances:

var launchRequest = new RunInstancesRequest()
    {
        ImageId = amiID,
        InstanceType = type,
        MinCount = 1,
        MaxCount = 1,
        SecurityGroupIds = groups
    };
    var launchResponse = ec2Client.RunInstances(launchRequest);
    var instances = launchResponse.Reservation.Instances;
    var myInstance = instances.First();

解决方案

You need to set the (integer GiB) value of the VolumeSize of the EbsBlockDevice in the launchRequest.BlockDeviceMappings before launch.

Remember that if you specify a snapshot, the volume size must be equal to or larger than the snapshot size. Also, if you're creating the volume from a snapshot and don't specify a volume size, the default is the snapshot size.

TIP: Always check the Boolean value of DeleteOnTermination as well and do not assume it has a default value of True for root volumes as in AWS console.

You can find out more on EbsBlockDevice properties here

这篇关于AWS的.Net SDK与特定的EBS卷大小创建一个Amazon EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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