脚本宝典收集整理的这篇文章主要介绍了如何使用php aws sdk启动和停止ec2实例,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$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凭据…希望这会让您指向正确的方向……
以上是脚本宝典为你收集整理的如何使用php aws sdk启动和停止ec2实例全部内容,希望文章能够帮你解决如何使用php aws sdk启动和停止ec2实例所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。