0
votes


    $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
                )
            )
        )
       ));

What is wrong with this, it does not work and I get no error?

1
How does it "not work" ? What are you not seeing that you are expecting to see?Matt Houser
Thx for replying. When I remove the BlockDeviceMappings part, I was able to launch the instance, but only with 8GB (default) disk size. When I add it back again, I get no error, it just does not create/launch the server.Liam Neil Parker

1 Answers

0
votes

Your BlockDeviceMappings part is not structured correctly.

You have DeviceName outside the second array structure, where it should be inside.

Try this:

$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(
        array(
            'DeviceName' => '/dev/sda1',
            'Ebs' => array(
                'SnapshotId' => 'snap-2337bd2a',
                'VolumeSize' => $disksize,
                'DeleteOnTermination' => true,
                'VolumeType' => 'gp2',
                'Encrypted' => false
            )
        )
    )
));