aws ec2 php,如何使用php aws sdk启动和停止ec2实例
以下是從定義的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憑據…希望這會讓您指向正確的方向……
總結
以上是生活随笔為你收集整理的aws ec2 php,如何使用php aws sdk启动和停止ec2实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【技术累积】【点】【java】【27】@
- 下一篇: 18.phpmyadmin 4.8.1