0

之后,我使用runInstances如下方法启动和实例:

$new_instance_config = array(
            'DryRun' => false,
            'ImageId' => AMI_ID,
            'MinCount' => 1,
            'MaxCount' => 1,
            'InstanceType' => 't1.micro',
            'Placement' => array(
                'AvailabilityZone' => AVAILABILITY_ZONE,
            ),
            'Monitoring' => array(
                'Enabled' => false,
            ),
            'NetworkInterfaces' => array(
                array(
                    'SubnetId' => SUBNET_ID,
                    'DeviceIndex' => 0,
                    'AssociatePublicIpAddress' => true,
                    'DeleteOnTermination' => true,
                    'Groups' => unserialize(SECURITY_GROUP_IDS)
                )
            )
        );

$res = $this->ec2Client->runInstances($new_instance_config);
echo json_encode($res);

{}但是,即使我登录 AWS 控制台,这也只会打印空白对象,我可以看到实例已启动。

我需要访问一些信息,例如AMI ID已启动实例的信息。我错过了什么吗?

4

1 回答 1

1

请参阅建模响应

尝试:

$res['Instances']

或者

$res->get('Instances')
于 2016-04-07T02:32:28.083 回答