pretty new with the aws sdk, looking to start. i've installed the sdk and everything but how do I start the ec2 instances using the php sdk? Some code samples would really be useful.
Here is a basic example of starting a machine from a defined 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";
}
This is assuming you have your AWS credentials setup properly ... Hopefully this gets you pointed in the right direction ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With