Amazon AWS SDK Installation Guide

Browse online or download Installation Guide for Software Amazon AWS SDK. Amazon AWS SDK Installation guide User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 151
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews

Summary of Contents

Page 1 - AWS SDK for PHP

AWS SDK for PHPversion 2.5.2Amazon Web ServicesJanuary 29, 2014

Page 2

Creating snapshots 99Events 99API Reference 100Amazon Route 53 100Creating a client 101Factory method 101Service builder 101API Reference 101Amazon Si

Page 3 - Contents

CancelJob CreateJobCreatePipeline CreatePresetDeletePipeline DeletePresetListJobsByPipeline ListJobsByStatusListPipelines ListPresetsReadJob ReadPipel

Page 4

This guide is incompleteThis guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of theAWS PHP com

Page 5

A more robust way to connect to Amazon Glacier is through the service builder. This allows you to specifycredentials and other configuration settings

Page 6

use Aws\Iam\IamClient;$client = IamClient::factory(array( 'key' => '<aws access key>', 'secret' =>

Page 7

DeleteSigningCertificate DeleteUserDeleteUserPolicy DeleteVirtualMFADeviceEnableMFADevice GetAccountPasswordPolicyGetAccountSummary GetGroupGetGroupPo

Page 8

You can provide your access keys like in the preceding example, or you can choose to omit them if you are usingAWS Identity and Access Management (IAM

Page 9

'secret' => '<aws secret key>', 'region' => '<region name>'));You can provide your ac

Page 10

AWS OpsWorksThis guide focuses on the AWS SDK for PHP client for AWS OpsWorks. This guide assumes that you have alreadydownloaded and installed the AW

Page 11

AttachElasticLoadBalancer CloneStackCreateApp CreateDeploymentCreateInstance CreateLayerCreateStack CreateUserProfileDeleteApp DeleteInstanceDeleteLay

Page 12

use Aws\Rds\RdsClient;$client = RdsClient::factory(array( 'key' => '<aws access key>', 'secret' =>

Page 13

Factory method 113Service builder 114Creating domains 114List all domains 114Retrieving a domain 114Adding items 114Retrieving items 115GetAttributes

Page 14 - Installation

DescribeDBParameterGroups DescribeDBParametersDescribeDBSecurityGroups DescribeDBSnapshotsDescribeDBSubnetGroups DescribeEngineDefaultParametersDescri

Page 15 - Installing via Phar

$aws = Aws::factory('/path/to/my_config.json');// Get the client from the builder by namespace$client = $aws->get('Redshift');C

Page 16 - Getting Started Guide

$events = $client->getIterator('DescribeEvents', array( 'StartTime' => strtotime('-3 days'), 'EndTime&

Page 17 - Creating a client object

Creating a clientFirst you need to create a client object using one of the following techniques.Factory methodThe easiest way to get up and running qu

Page 18 - Performing service operations

Amazon Simple Storage ServiceThis guide focuses on the AWS SDK for PHP client for Amazon Simple Storage Service. This guide assumes thatyou have alrea

Page 19 - Detecting and handling errors

// Create a valid bucket and use a LocationConstraint$result = $client->createBucket(array( 'Bucket' => $bucket, &ap

Page 20 - Migration Guide

// Upload an object by streaming the contents of a file// $pathToFile should be absolute path to a file on disk$result = $client->putObject(array(

Page 21 - What's Different?

// Grab the nested Owner/ID value from the result model using getPath()$result = $client->listBuckets();echo $result->getPath('Owner/ID&apo

Page 22 - Service Operations

// Seek to the beginning of the stream$result['Body']->rewind();// Read the body off of the underlying stream in chunkswhile ($data = $re

Page 23 - Exceptions

->setKey('my-object-key') ->setConcurrency(3) ->build();You can use the Aws\S3\S3Client::upload() method if you just want

Page 24 - Iterators

Amazon Simple Workflow Service 125Creating a client 125Factory method 125Service builder 126API Reference 126DynamoDB Session Handler 127Introduction

Page 25 - From Version 1 of the SDK

The most common scenario is creating a pre-signed URL to GET an object. The easiest way to do this is to use thegetObjectUrl method of the Amazon S3 c

Page 26

echo file_get_contents($signedUrl);// > Hello!Amazon S3 stream wrapperThe Amazon S3 stream wrapper allows you to store and retrieve data from Amazo

Page 27 - Side-by-side Guide

'debug' => true));More control with the UploadSyncBuilderThe uploadDirectory() method is an abstraction layer over the much mor

Page 28 - Without Composer

debug Set to true to enable debug mode to print information about each download. Setting this value to anfopen resource will write the debug output to

Page 29 - Complete Examples

GetBucketLocation (service docs) GetBucketLogging (service docs)GetBucketNotification (service docs) GetBucketPolicy (service docs)GetBucketRequestPay

Page 30

use Aws\Common\Aws;// Create a service builder using a configuration file$aws = Aws::factory('/path/to/my_config.json');// Get the client fr

Page 31 - Introduction

'key' => '<aws access key>', 'secret' => '<aws secret key>', 'region'

Page 32 - Caching IAM role credentials

After creating a domain, you are ready to start putting data into it. Domains consist of items, which are described byattribute name-value pairs. Item

Page 33

Because some responses will be truncated and require subsequent requests, it is recommended to always use theSelect iterator to easily retrieve an ent

Page 34

A region parameter is also required and must be set to one of the following values: us-east-1,ap-northeast-1, sa-east-1, ap-southeast-1, ap-southeast-

Page 35

AWS SDK for PHPSigning Up for AWSImportantThis page is obsolete. Please see About Access Keys.Creating an AWS accountBefore you begin, you need to cre

Page 36 - Getting temporary credentials

RemovePermission SetEndpointAttributesSetPlatformApplicationAttributes SetSubscriptionAttributesSetTopicAttributes SubscribeUnsubscribeAmazon Simple Q

Page 37 - Configuring the SDK

use Aws\Common\Enum\Size;use Aws\Sqs\Enum\QueueAttribute;$result = $client->createQueue(array( 'QueueName' => 'my-queue'

Page 38

$result = $client->receiveMessage(array( 'QueueUrl' => $queueUrl, 'WaitTimeSeconds' => 10,));NoteYou can als

Page 39 - Client configuration options

Service builderA more robust way to connect to AWS Storage Gateway is through the service builder. This allows you to specifycredentials and other con

Page 40 - Setting a custom endpoint

RetrieveTapeRecoveryPoint ShutdownGatewayStartGateway UpdateBandwidthRateLimitUpdateChapCredentials UpdateGatewayInformationUpdateGatewaySoftwareNow U

Page 41 - Command Objects

AWS STS has five operations that return temporary credentials: AssumeRole, AssumeRoleWithWebIdentity,AssumeRoleWithSAML, GetFederationToken, and GetSe

Page 42 - Using command objects

$credentials = $sts->createCredentials($sts->getSessionToken());$s3->setCredentials($credentials);This guide is incompleteThis guide is not q

Page 43 - Using requests and responses

use Aws\Common\Aws;// Create a service builder using a configuration file$aws = Aws::factory('/path/to/my_config.json');// Get the client fr

Page 44 - Basic Configuration

'region' => '<region name>'));You can provide your access keys like in the preceding example, or you can choose to om

Page 45 - Custom Waiters

SignalWorkflowExecution StartWorkflowExecutionTerminateWorkflowExecutionDynamoDB Session HandlerIntroductionThe DynamoDB Session Handler is a custom s

Page 46 - Waiter Definitions

NoteImportant: Your Secret Access Key is a secret, which only you and AWS should know. It is important to keepit confidential to protect your account.

Page 47

Before you can actually use the session handler, you need to create a table in which to store the sessions. This canbe done ahead of time through the

Page 48 - Iterator Events

gc_batch_size The batch size used for removing expired sessions during garbage collection. Thisdefaults to 25, which is the maximum size of a single B

Page 49 - Modeled Responses

Read via session_start()(UsingPessimisticLockingStrategy)• A minimum of 1 write operation.• (Conditional) Additional write operations for each attempt

Page 50 - Using data in the model

));$sessionHandler->garbageCollect();You can also use the gc_operation_delay configuration option on the session handler to introduce delays inbetw

Page 51 - Static Client Facades

} // Be sure to close the stream resource when you're done with it fclose($stream);}Opening Seekable streamsStreams opened in "r&q

Page 52 - Why Use Client Facades?

PHP's fopen() function requires that a $mode option is specified. The mode option specifies whether or not data canbe read or written to a stream

Page 53

copy() Copy an object from one location to another. You can pass options available to the CopyObjectoperation into the stream context options to modif

Page 54 - Performance Guide

Another easy way to list the contents of the bucket is using the Symfony2 Finder component.<?phprequire 'vendor/autoload.php';use Symfony

Page 55 - Modifying APC settings

• SDK Features• Iterators• Waiters• Command Objects• Parallel Commands• Modeled Responses• Static Client Facades• Frequently Asked Questions (FAQ)• Pe

Page 56 - Turn off parameter validation

• Amazon Glacier• Using the Amazon Glacier PHP client• PHP API reference• Amazon Kinesis• Using the Kinesis PHP client• PHP API reference• Amazon Reds

Page 57

}}Consider tightening your dependencies to a known version (e.g., 2.5.*).2. Download and install Composer.curl -sS https://getcomposer.org/install

Page 58 - Comparing SDK1 and SDK2

• Using the CloudTrail PHP client• PHP API reference• AWS Data Pipeline• Using the AWS Data Pipeline PHP client• PHP API reference• AWS Direct Connect

Page 59 - How do I disable SSL?

• Providing credentials to the AWS SDK for PHP• Using Credentials from AWS Security Token Service• Iterating through Amazon DynamoDB Results• Sending

Page 60

Installing via ZipEach release of the AWS SDK for PHP (since 2.3.2) ships with a zip file containing all of the classes anddependencies you need to ru

Page 61 - Auto Scaling

Using Composer require '/path/to/vendor/autoload.php';Using the Phar require '/path/to/aws.phar';Using the Zip require '/path

Page 62

Service builderAnother way to instantiate a service client is using the Aws\Common\Aws object (a.k.a the service builder). TheAws object is essentiall

Page 63 - AWS CloudFormation

Working with modeled responsesThe result of a performing an operation is what we refer to as a modeled response. Instead of returning the rawXML or JS

Page 65

In the following example, the Amazon S3 Client is used to create a bucket. Then the waiter method is used to waituntil the bucket exists.// Create a b

Page 66

• PHP 5.3 namespaces• Follows PSR-0, PSR-1, and PSR-2 standards• Built on Guzzle and utilizes the Guzzle feature set• Persistent connection management

Page 67

The SDK adopts the PSR standards produced by the PHP Framework Interop Group. An immediately noticeablechange is that all method names are now named u

Page 68

// New SDK - PutObject operation$result = $s3->putObject(array( 'Bucket' => 'bucket-name', 'Key' => &a

Page 69

Instead of relying on the CFResponse::isOK() method of the previous SDK to determine if an operation issuccessful, the new SDK throws exceptions when

Page 70 - Amazon CloudSearch

$s3 = new AmazonS3();$response = $s3->list_parts('my-bucket-name', 'my-object-key', 'my-upload-id', array( 'm

Page 71 - AWS CloudTrail

$people = array();// Perform as many Scan operations as needed to acquire all the names of people// that are 16 or olderdo{ // Setup the parameters

Page 72 - Amazon CloudWatch

print_r($people);From Version 2 of the SDK<?phprequire '/path/to/vendor/autoload.php';use Aws\Common\Aws;use Aws\DynamoDb\Enum\Comparison

Page 73

1. Add both of the SDKs as dependencies in your project's composer.json file.{ "require": { "aws/aws-sdk-php": &quo

Page 74 - AWS Data Pipeline

This will automatically set up the service clients from Version 1 of the SDK making them accessible through theservice builder by keys such as v1.s3 a

Page 75 - AWS Direct Connect

ContentsAWS SDK for PHP 1Signing Up for AWS 1Creating an AWS account 1To sign up for AWS 1To view your AWS credentials 1Getting your AWS credentials 1

Page 76 - Amazon DynamoDB

Example 1 - Dual Amazon S3 ClientsThis example demonstrates using an Amazon S3 client from the AWS SDK for PHP working side-by-side with anAmazon S3 c

Page 77 - Creating tables

'RangeKeyElement' => array('N' => $date->format('j')) )))->getResult()->getPath('Item/fla

Page 78 - Listing tables

• How many sets of credentials you are using• The type of project you are developing (e.g., application, CLI, library)• How often you rotate your cred

Page 79

The easiest way to add a cache to your IAM role credentials is to specify a credentials cache using thecredentials.cache option in a client's fac

Page 80 - Query and scan

The SDK provides a service builder that can be used to share configuration values across multiple clients. Theservice builder allows you to specify de

Page 81

// Instantiate the S3 client with your AWS credentials$s3Client = S3Client::factory(array( 'credentials' => $credentials));You may als

Page 82 - Local secondary indexes

NoteTemporary credentials generated by AWS STS are not supported by every service. Please check if the serviceyou are using supports temporary credent

Page 83

However, the best way to provide temporary credentials is to use the createCredentials() helper methodincluded with the StsClient. This method extract

Page 84 - Using the WriteRequestBatch

$aws = Aws::factory(array( 'key' => 'YOUR_AWS_ACCESS_KEY_ID', 'secret' => 'YOUR_AWS_SECRET_ACCESS_KE

Page 85 - Amazon DynamoDB (2011-12-05)

) ));If you prefer JSON syntax, you can define your configuration in JSON format instead of PHP.{ "includes": ["_aws"

Page 86

Iterators 12Comparing Code Samples from Both SDKs 12Example 1 - Amazon S3 ListParts Operation 12From Version 1 of the SDK 12From Version 2 of the SDK

Page 87

signature.service The signature service scope for Signature V4. See Setting a custom endpoint.signature.region The signature region scope for Signatur

Page 88

$client = DynamoDbClient::factory(array( 'base_url' => 'http://my-custom-url', 'region' => 'my-region

Page 89

$command = $dynamoDbClient->getCommand('DescribeTable', array( 'TableName' => 'YourTableName',));$result = $com

Page 90

// 2. Prepare$command->prepare();$request = $command->getRequest();// Note: `prepare()` also returns the request object// 3. Execute$command->

Page 91 - Amazon Elastic Compute Cloud

// Execute an array of command objects to do them in parallel$s3Client->execute($commands);// Loop over the commands, which have now all been execu

Page 92

$s3Client->waitUntilBucketExists(array( 'Bucket' => 'my-bucket', 'waiter.interval' => 10

Page 93

namespace MyApp\FakeWaiters{ use Aws\Common\Waiter\AbstractResourceWaiter; class SleptThreeTimes extends AbstractResourceWaiter { publ

Page 94 - Amazon ElastiCache

'VaultExists' => array( 'extends' => '__VaultState', 'success.type' =>

Page 95

Iterator ObjectsThe actual object returned by getIterator(), and any get[…]Iterator() method, is an instance of theAws\Common\Iterator\AwsResourceIter

Page 96 - AWS Elastic Beanstalk

echo "Results received. {$requestCount} request(s) made so far.\n";});foreach ($iterator as $object) { echo $object['Key']

Page 97 - Elastic Load Balancing

A peek under the hood 29Using command objects 30Manipulating command objects before execution 30Request and response objects 30Managing command state

Page 98 - Amazon Elastic Transcoder

}$isDeleted = (bool) $result->get('DeleteMarker');Of course, you can still use isset() checks if you want to, since Model does implement

Page 99

Response Models contain the parsed data from the response from a service operation, so the contents of the modelwill be different depending on which o

Page 100 - Amazon Elastic MapReduce

Version 2.4 of the AWS SDK for PHP adds the ability to enable and use static client "facades". These facadesprovide an easy, static interfac

Page 101 - Amazon Glacier

'Body' => fopen($file, 'r'),));echo "\nCreated a new object: {$result['ObjectURL']}\n";You can also mou

Page 102 - Creating a client

->method('listBuckets') ->will($this->returnValue(new Model(array( 'Buckets' =>

Page 103

We have taken great care to ensure that the SDK will perform well in an environment that utilizes an opcode cache.NotePHP 5.5 comes with an opcode cac

Page 104 - AWS Import/Export

From the PHP documentationThis defaults to on, forcing APC to stat (check) the script on each request to determine if it has been modified. Ifit has b

Page 105 - Amazon Kinesis

'validation' => false));Cache instance profile credentialsWhen you do not provide credentials to the SDK and do not have credentials

Page 106 - Creating a stream

Profile your code to find performance bottlenecksYou will need to profile your application to determine the bottlenecks. This can be done using Xdebug

Page 107 - AWS OpsWorks

$aws = Aws\Common\Aws::factory(array( 'region' => 'us-west-2', 'key' => '****', 'secret

Page 108

Turn off parameter validation 44Cache instance profile credentials 45Check if you are being throttled 45Preload frequently included files 45Profile yo

Page 109

use Guzzle\Common\Log\MonologLogAdapter;use Guzzle\Plugin\Log\LogPlugin;use Monolog\Logger;use Monolog\Handler\StreamHandler;// Create a log channel$l

Page 110 - Amazon Redshift

...Or by using the the tilde operator. The following statement is equivalent to >=2.4.9,<2.5:{ "require": { "aws/aws-sd

Page 111 - Creating snapshots

use Aws\AutoScaling\AutoScalingClient;$client = AutoScalingClient::factory(array( 'key' => '<aws access key>', &

Page 112 - Amazon Route 53

DescribeTags DescribeTerminationPolicyTypesDisableMetricsCollection EnableMetricsCollectionExecutePolicy PutNotificationConfigurationPutScalingPolicy

Page 113

This guide is incompleteThis guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of theAWS PHP com

Page 114 - Amazon Simple Storage Service

// Create a service builder using a configuration file$aws = Aws::factory('/path/to/my_config.json');// Get the client from the builder by n

Page 115 - Uploading objects

$signedUrlCannedPolicy = $cloudFront->getSignedUrl(array( 'url' => $streamHostUrl . '/' . $resourceKey, '

Page 116 - Listing your buckets

ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send apull request to https://github.com/aws/aws-s

Page 117 - Downloading objects

A more robust way to connect to Amazon CloudFront is through the service builder. This allows you to specifycredentials and other configuration settin

Page 118 - Saving objects to a file

'url' => $streamHostUrl . '/' . $resourceKey, 'expires' => $expires,));For versions of the SDK later th

Page 119 - Creating a pre-signed URL

Factory method 58Service builder 59API Reference 59AWS CloudTrail 59Creating a client 59Factory method 59Service builder 60Blog articles 60API Referen

Page 120

This guide is incompleteThis guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of theAWS PHP com

Page 121 - Syncing data with Amazon S3

Service builderA more robust way to connect to Amazon CloudSearch is through the service builder. This allows you to specifycredentials and other conf

Page 122 - Customizing the download sync

A region parameter is also required and must be set to one of the following values: us-west-2, us-east-1use Aws\CloudTrail\CloudTrailClient;$client =

Page 123 - Cleaning up

This guide focuses on the AWS SDK for PHP client for Amazon CloudWatch. This guide assumes that you havealready downloaded and installed the AWS SDK f

Page 124 - Amazon Simple Email Service

DescribeAlarms DescribeAlarmsForMetricDisableAlarmActions EnableAlarmActionsGetMetricStatistics ListMetricsPutMetricAlarm PutMetricDataSetAlarmStateAW

Page 125 - Amazon SimpleDB

pull request to https://github.com/aws/aws-sdk-php. You can view our documentation sources athttps://github.com/aws/aws-sdk-php/tree/master/docs.API R

Page 126 - Adding items

$aws = Aws::factory('/path/to/my_config.json');// Get the client from the builder by namespace$client = $aws->get('DirectConnect&apo

Page 127 - Retrieving items

'key' => '<aws access key>', 'secret' => '<aws secret key>', 'region'

Page 128 - Deleting domains

// Wait until the table is created and active$client->waitUntilTableExists(array( 'TableName' => 'errors'));A full list o

Page 129

echo $tableName . "\n";}Iterating over all tablesThe result of a listTables() operation might be truncated. Because of this, it is usual

Page 130 - Amazon Simple Queue Service

API Reference 73Amazon DynamoDB (2011-12-05) 73Creating a client 73Factory method 73Service builder 74Creating tables 74Updating a table 74Describing

Page 131 - Receiving messages

Retrieving itemsYou can check if the item was added correctly using the getItem() method of the client. Because AmazonDynamoDB works under an 'ev

Page 132 - AWS Storage Gateway

Let's say we want a list of all "1201" errors that occurred in the last 15 minutes. We could issue a single query thatwill search by th

Page 133

echo $item['error']['S'] . "\n";}Deleting itemsTo delete an item you must use the DeleteItem() method. The following

Page 134 - AWS Security Token Service

'KeySchema' => array( array('AttributeName' => 'CustomerId', 'KeyType' => 'HASH'

Page 135 - Using Temporary Credentials

array( 'PutRequest' => array( 'Item' => array( 'Cu

Page 136 - AWS Support

'id' => $itemId, 'timestamp' => time(), )); $putBatch->add(new PutRequest($item, $tableName))

Page 137

'region' => '<region name>', 'version' => '2011-12-05'));You can provide your access keys

Page 138

// Update the provisioned throughput capacity of the table$client->updateTable(array( 'TableName' => 'errors', 'P

Page 139 - DynamoDB Session Handler

TipYou can convert an iterator to an array using the toArray() method of the iterator.Adding itemsYou can add an item to our errors table using the pu

Page 140 - Configuration

echo $result['Item']['message']['S'] . "\n";//> no vacant areasYou can also retrieve items in batches of up

Page 141

API Reference 87Amazon Elastic MapReduce 88Creating a client 88Factory method 88Service builder 88API Reference 89Amazon Glacier 89Creating a client 8

Page 142 - Garbage Collection

echo $item['error']['S'] . "\n";}ScanA scan operation scans the entire table. You can specify filters to apply to th

Page 143 - Amazon S3 Stream Wrapper

If you have a large array of items you wish to add to your table, you could iterate over the them, add each item to thebatch object. After all the ite

Page 144 - Uploading data

The easiest way to get up and running quickly is to use the Aws\Ec2\Ec2Client::factory() method andprovide your credentials (key and secret).A region

Page 145 - Other object functions

CancelConversionTask CancelExportTaskCancelReservedInstancesListing CancelSpotInstanceRequestsConfirmProductInstance CopyImageCopySnapshot CreateCusto

Page 146 - Working with buckets

DescribeSnapshots DescribeSpotDatafeedSubscriptionDescribeSpotInstanceRequests DescribeSpotPriceHistoryDescribeSubnets DescribeTagsDescribeVolumeAttri

Page 147 - In-Depth Guides

A region parameter is also required and must be set to one of the following values: us-east-1,ap-northeast-1, sa-east-1, ap-southeast-1, ap-southeast-

Page 148 - Service-Specific Guides

DescribeEvents DescribeReplicationGroupsDescribeReservedCacheNodes DescribeReservedCacheNodesOfferingsModifyCacheCluster ModifyCacheParameterGroupModi

Page 149

ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send apull request to https://github.com/aws/aws-s

Page 150 - Articles from the Blog

You can provide your access keys like in the preceding example, or you can choose to omit them if you are usingAWS Identity and Access Management (IAM

Page 151 - Presentations

This guide focuses on the AWS SDK for PHP client for Amazon Elastic Transcoder. This guide assumes that youhave already downloaded and installed the A

Comments to this Manuals

No comments