Created
March 11, 2013 17:08
-
-
Save dkl4/5135777 to your computer and use it in GitHub Desktop.
This is a simple file which will show sample output from Amazon Web Services PHP SDK 2. Sample focuses on EC2 "Describe" commands.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Sample "Hello AWS PHP SDK 2" script | |
// March, 2013 | |
require '/your-path/vendor/autoload.php'; | |
require '/your-path/vendor/aws/aws-sdk-php/src/Aws/Ec2/Ec2Client.php'; | |
use Aws\Common\Aws; | |
use Aws\Common\Enum\Region; | |
use Aws\EC2\Ec2Client; | |
$client = Ec2Client::factory(array( | |
'key' => 'YOUR-KEY', | |
'secret' => 'your-secret', | |
'region' => Region::US_EAST_2, | |
)); | |
$descCmdsAry = getCommandsAry(); // defined below | |
// Now print output from all EC2 Describe commands -- except for a few long ones | |
foreach ($descCmdsAry as $cmd => $result) { | |
print "<h2>$cmd ==> $result</h2> \n"; | |
print "<pre> \n"; | |
try { | |
$obj = $client->$cmd(); | |
} catch (Exception $e) { | |
print $e; | |
} | |
print_r($obj[$result]); | |
print "</pre>\n"; | |
} | |
function getCommandsAry () { | |
return array( | |
'DescribeAddresses' => 'Addresses', | |
'DescribeAvailabilityZones' => 'AvailabilityZones', | |
'DescribeBundleTasks' => 'BundleTasks', | |
'DescribeConversionTasks' => 'ConversionTasks', | |
'DescribeCustomerGateways' => 'CustomerGateways', | |
'DescribeDhcpOptions' => 'DhcpOptions', | |
'DescribeExportTasks' => 'ExportTasks', | |
'DescribeImageAttribute' => 'ImageAttribute', // Need input attribute or error | |
//'DescribeImages' => 'Images', // Too many without filter | |
'DescribeInstanceAttribute' => 'InstanceAttribute', // Need input attribute or error | |
'DescribeInstanceStatus' => 'InstanceStatus', | |
'DescribeInstances' => 'Instances', | |
'DescribeInternetGateways' => 'InternetGateways', | |
'DescribeKeyPairs' => 'KeyPairs', | |
'DescribeLicenses' => 'Licenses', // UnsupportedOperation | |
'DescribeNetworkAcls' => 'NetworkAcls', | |
'DescribeNetworkInterfaceAttribute' => 'NetworkInterfaceAttribute', // Need input attribute or error | |
'DescribeNetworkInterfaces' => 'NetworkInterfaces', | |
'DescribePlacementGroups' => 'PlacementGroups', | |
'DescribeRegions' => 'Regions', | |
'DescribeReservedInstances' => 'ReservedInstances', | |
'DescribeReservedInstancesListings' => 'ReservedInstancesListings', | |
//'DescribeReservedInstancesOfferings' => 'ReservedInstancesOfferings', // Too many with out filter | |
'DescribeRouteTables' => 'RouteTables', | |
//'DescribeSecurityGroups' => 'SecurityGroups', // Several (18) many from AWS | |
'DescribeSnapshotAttribute' => 'SnapshotAttribute', // Need input attribute or error | |
//'DescribeSnapshots' => 'Snapshots', // Very long (2500) need filter | |
'DescribeSpotDatafeedSubscription' => 'SpotDatafeedSubscription', // InvalidSpotDatafeed.NotFound | |
'DescribeSpotInstanceRequests' => 'SpotInstanceRequests', | |
//'DescribeSpotPriceHistory' => 'SpotPriceHistory', // Long - 800 | |
'DescribeSubnets' => 'Subnets', | |
'DescribeTags' => 'Tags', | |
'DescribeVolumeAttribute' => 'VolumeAttribute', // Need input attribute or error | |
'DescribeVolumeStatus' => 'VolumeStatus', | |
'DescribeVolumes' => 'Volumes', | |
'DescribeVpcs' => 'Vpcs', | |
'DescribeVpnConnections' => 'VpnConnections', | |
'DescribeVpnGateways' => 'VpnGateways', | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment