适用于PHP 2的AWS开发工具包-创建实例时更改根卷大小 [英] AWS SDK for PHP 2 - Change root volume size when creating an Instance

查看:128
本文介绍了适用于PHP 2的AWS开发工具包-创建实例时更改根卷大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用但是,API的要点是能够在十分之一的时间内和使用自己的代码来完成您可以使用亚马逊网站上的前端执行的所有操作.

However, the point of the API is to be able to do everything you can do with the front-end on the amazon website, in a tenth of the time and with your own code.

考虑到这一点,我需要执行以下操作:

With that in mind, I need to do the following:

在前端,我可以将卷大小更改为40GB.

On the front-end, I can change the Volume Size to, say, 40GB.

使用PHP创建新实例时,我如何要求40GB的卷大小?甚至可以在实例创建后运行,只要它是自动运行的-我应该能够以编程方式执行此操作.

How can I ask for a 40GB Volume Size when creating a new Instance with PHP? It could even be run after the instance is created, as long as it's automatic - I should be able to do this programatically.

如何使用适用于PHP 2的AWS开发工具包实现我的要求?

How can I achieve what I require using the AWS SDK for PHP 2?

推荐答案

看起来您在正确的轨道上.在文档中runInstances()的a>中,有一个参数BlockDeviceMappings包含另一个参数Ebs,该参数包含您要查找的VolumeSize参数.这是未经测试的代码.

It looks like you're on the right track. In the documentation for runInstances(), there is a parameter BlockDeviceMappings that contains another parameter Ebs that contains the paramenter you're looking for VolumeSize. This is untested code.

$instance = $ec2->runInstances(array(
'ImageId'                => AMI_ID,      // AMI ID
'InstanceType'           => AMI_TYPE,    // m1.medium etc.
'MinCount'               => 1,           // Minimum to create
'MaxCount'               => 1,           // Maximum to create
'SecurityGroups'         => SEC_NAME,    // Security Group Name
'KeyName'                => KEY_NAME,    // Key Pair to use
'BlockDeviceMappings' => array(          // How block devices are mapped to instance
   array(
     'Ebs' => array(                     // EBS Volume Info
        array(
            'VolumeSize' => 40           // Volume Size
        )
    )
)
)
))->toArray();                           // Get back our data in an array

这篇关于适用于PHP 2的AWS开发工具包-创建实例时更改根卷大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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