以下是从定义的AMI启动计算机的基本示例:
$image_id = 'ami-3d4ff254'; //Ubuntu 12.04 $min = 1; //the minimum number of instances to start $max = 1; //the maximum number of instances to start $options = array( 'SecurityGroupId' => 'default',//replace with your security group id 'InstanceType' => 't1.micro','KeyName' => 'keypair',//the name of your keypair for auth 'InstanceInitiatedShutdownBehavior' => 'terminate' //terminate on shutdown ); require_once('AWSSDKforPHP/sdk.class.PHP'); $ec2 = new AmazonEC2(); $response = $ec2->run_instances($image_id,$min,$max,$options); if(!$response->isOK()){ echo "Start Failed\n"; }
这是假设您正确设置了您的AWS凭据…希望这会让您指向正确的方向……