Amazon AWS SDK Guia de Instalação

Consulte online ou descarregue Guia de Instalação para Software Amazon AWS SDK. Amazon AWS SDK Installation guide Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 151
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes

Resumo do Conteúdo

Página 1 - AWS SDK for PHP

AWS SDK for PHPversion 2.5.2Amazon Web ServicesJanuary 29, 2014

Página 2

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

Página 3 - Contents

CancelJob CreateJobCreatePipeline CreatePresetDeletePipeline DeletePresetListJobsByPipeline ListJobsByStatusListPipelines ListPresetsReadJob ReadPipel

Página 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

Página 5

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

Página 6

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

Página 7

DeleteSigningCertificate DeleteUserDeleteUserPolicy DeleteVirtualMFADeviceEnableMFADevice GetAccountPasswordPolicyGetAccountSummary GetGroupGetGroupPo

Página 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

Página 9

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

Página 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

Página 11

AttachElasticLoadBalancer CloneStackCreateApp CreateDeploymentCreateInstance CreateLayerCreateStack CreateUserProfileDeleteApp DeleteInstanceDeleteLay

Página 12

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

Página 13

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

Página 14 - Installation

DescribeDBParameterGroups DescribeDBParametersDescribeDBSecurityGroups DescribeDBSnapshotsDescribeDBSubnetGroups DescribeEngineDefaultParametersDescri

Página 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

Página 16 - Getting Started Guide

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

Página 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

Página 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

Página 19 - Detecting and handling errors

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

Página 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(

Página 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

Página 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

Página 23 - Exceptions

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

Página 24 - Iterators

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

Página 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

Página 26

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

Página 27 - Side-by-side Guide

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

Página 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

Página 29 - Complete Examples

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

Página 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

Página 31 - Introduction

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

Página 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

Página 33

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

Página 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-

Página 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

Página 36 - Getting temporary credentials

RemovePermission SetEndpointAttributesSetPlatformApplicationAttributes SetSubscriptionAttributesSetTopicAttributes SubscribeUnsubscribeAmazon Simple Q

Página 37 - Configuring the SDK

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

Página 38

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

Página 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

Página 40 - Setting a custom endpoint

RetrieveTapeRecoveryPoint ShutdownGatewayStartGateway UpdateBandwidthRateLimitUpdateChapCredentials UpdateGatewayInformationUpdateGatewaySoftwareNow U

Página 41 - Command Objects

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

Página 42 - Using command objects

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

Página 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

Página 44 - Basic Configuration

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

Página 45 - Custom Waiters

SignalWorkflowExecution StartWorkflowExecutionTerminateWorkflowExecutionDynamoDB Session HandlerIntroductionThe DynamoDB Session Handler is a custom s

Página 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.

Página 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

Página 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

Página 49 - Modeled Responses

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

Página 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

Página 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

Página 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

Página 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

Página 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

Página 55 - Modifying APC settings

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

Página 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

Página 57

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

Página 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

Página 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

Página 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

Página 61 - Auto Scaling

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

Página 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

Página 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

Página 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

Página 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

Página 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

Página 68

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

Página 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

Página 70 - Amazon CloudSearch

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

Página 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

Página 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

Página 73

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

Página 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

Página 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

Página 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

Página 77 - Creating tables

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

Página 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

Página 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

Página 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

Página 81

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

Página 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

Página 83

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

Página 84 - Using the WriteRequestBatch

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

Página 85 - Amazon DynamoDB (2011-12-05)

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

Página 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

Página 87

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

Página 88

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

Página 89

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

Página 90

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

Página 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

Página 92

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

Página 93

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

Página 94 - Amazon ElastiCache

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

Página 95

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

Página 96 - AWS Elastic Beanstalk

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

Página 97 - Elastic Load Balancing

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

Página 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

Página 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

Página 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

Página 101 - Amazon Glacier

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

Página 102 - Creating a client

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

Página 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

Página 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

Página 105 - Amazon Kinesis

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

Página 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

Página 107 - AWS OpsWorks

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

Página 108

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

Página 109

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

Página 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

Página 111 - Creating snapshots

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

Página 112 - Amazon Route 53

DescribeTags DescribeTerminationPolicyTypesDisableMetricsCollection EnableMetricsCollectionExecutePolicy PutNotificationConfigurationPutScalingPolicy

Página 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

Página 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

Página 115 - Uploading objects

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

Página 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

Página 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

Página 118 - Saving objects to a file

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

Página 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

Página 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

Página 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

Página 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 =

Página 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

Página 124 - Amazon Simple Email Service

DescribeAlarms DescribeAlarmsForMetricDisableAlarmActions EnableAlarmActionsGetMetricStatistics ListMetricsPutMetricAlarm PutMetricDataSetAlarmStateAW

Página 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

Página 126 - Adding items

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

Página 127 - Retrieving items

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

Página 128 - Deleting domains

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

Página 129

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

Página 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

Página 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

Página 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

Página 133

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

Página 134 - AWS Security Token Service

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

Página 135 - Using Temporary Credentials

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

Página 136 - AWS Support

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

Página 137

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

Página 138

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

Página 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

Página 140 - Configuration

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

Página 141

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

Página 142 - Garbage Collection

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

Página 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

Página 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

Página 145 - Other object functions

CancelConversionTask CancelExportTaskCancelReservedInstancesListing CancelSpotInstanceRequestsConfirmProductInstance CopyImageCopySnapshot CreateCusto

Página 146 - Working with buckets

DescribeSnapshots DescribeSpotDatafeedSubscriptionDescribeSpotInstanceRequests DescribeSpotPriceHistoryDescribeSubnets DescribeTagsDescribeVolumeAttri

Página 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-

Página 148 - Service-Specific Guides

DescribeEvents DescribeReplicationGroupsDescribeReservedCacheNodes DescribeReservedCacheNodesOfferingsModifyCacheCluster ModifyCacheParameterGroupModi

Página 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

Página 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

Página 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

Comentários a estes Manuais

Sem comentários