如何在PHP中使用runInstance调整Root Disk的大小

时间:2015-08-16 21:17:27

标签: amazon-web-services amazon-ec2



    $cmd = 'runInstances';
       $result = $client->$cmd(array(
        'ImageId' => selectAMI($_POST['dc'], $_POST['os']),
        'MinCount' => 1,
        'MaxCount' => 1,
        'InstanceType' => $_POST['itype'],
        'KeyName' => $_POST['key'],
        'SecurityGroups' => array($securityGroupName),
        'BlockDeviceMappings' => array(
            'DeviceName' => '/dev/sda1',
            array(
                'Ebs' => array(
                    'SnapshotId' => 'snap-2337bd2a',
                    'VolumeSize' => $disksize,
                    'DeleteOnTermination' => true,
                    'VolumeType' => 'gp2',
                    'Encrypted' => false
                )
            )
        )
       ));

这有什么问题,它不起作用,我没有错误?

1 个答案:

答案 0 :(得分:0)

您的If there is a different number of arguments than there are parameters, no error is raised; JavaScript is perfectly fine with this situation and deals with it as follows: ■ If more arguments are supplied than there are parameters, the “excess” arguments are simply not assigned to parameter names. For example, let’s say that we have a function declared as function whatever(a,b,c) { ... } If we were to call it with whatever(1,2,3,4,5), the arguments, 1, 2, and 3 would be assigned to a, b, and c, respectively. Arguments 4 and 5 are unassigned to any parameters. ■ If there are more parameters than there are arguments, the parameters that have no corresponding argument are set to undefined. For example, if we were to call the whatever(a,b,c) function with whatever(1), parameter a would be assigned the value 1, and b and c would be set to undefined. 部分结构不正确。

您在第二个BlockDeviceMappings结构之外DeviceName,它应该在里面。

试试这个:

array