Amazon AWS SDK Przewodnik Instalacji

Przeglądaj online lub pobierz Przewodnik Instalacji dla Oprogramowanie Amazon AWS SDK. Amazon AWS SDK Installation guide Instrukcja obsługi

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 151
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów

Podsumowanie treści

Strona 1 - AWS SDK for PHP

AWS SDK for PHPversion 2.5.2Amazon Web ServicesJanuary 29, 2014

Strona 2

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

Strona 3 - Contents

CancelJob CreateJobCreatePipeline CreatePresetDeletePipeline DeletePresetListJobsByPipeline ListJobsByStatusListPipelines ListPresetsReadJob ReadPipel

Strona 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

Strona 5

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

Strona 6

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

Strona 7

DeleteSigningCertificate DeleteUserDeleteUserPolicy DeleteVirtualMFADeviceEnableMFADevice GetAccountPasswordPolicyGetAccountSummary GetGroupGetGroupPo

Strona 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

Strona 9

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

Strona 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

Strona 11

AttachElasticLoadBalancer CloneStackCreateApp CreateDeploymentCreateInstance CreateLayerCreateStack CreateUserProfileDeleteApp DeleteInstanceDeleteLay

Strona 12

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

Strona 13

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

Strona 14 - Installation

DescribeDBParameterGroups DescribeDBParametersDescribeDBSecurityGroups DescribeDBSnapshotsDescribeDBSubnetGroups DescribeEngineDefaultParametersDescri

Strona 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

Strona 16 - Getting Started Guide

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

Strona 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

Strona 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

Strona 19 - Detecting and handling errors

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

Strona 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(

Strona 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

Strona 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

Strona 23 - Exceptions

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

Strona 24 - Iterators

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

Strona 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

Strona 26

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

Strona 27 - Side-by-side Guide

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

Strona 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

Strona 29 - Complete Examples

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

Strona 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

Strona 31 - Introduction

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

Strona 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

Strona 33

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

Strona 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-

Strona 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

Strona 36 - Getting temporary credentials

RemovePermission SetEndpointAttributesSetPlatformApplicationAttributes SetSubscriptionAttributesSetTopicAttributes SubscribeUnsubscribeAmazon Simple Q

Strona 37 - Configuring the SDK

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

Strona 38

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

Strona 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

Strona 40 - Setting a custom endpoint

RetrieveTapeRecoveryPoint ShutdownGatewayStartGateway UpdateBandwidthRateLimitUpdateChapCredentials UpdateGatewayInformationUpdateGatewaySoftwareNow U

Strona 41 - Command Objects

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

Strona 42 - Using command objects

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

Strona 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

Strona 44 - Basic Configuration

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

Strona 45 - Custom Waiters

SignalWorkflowExecution StartWorkflowExecutionTerminateWorkflowExecutionDynamoDB Session HandlerIntroductionThe DynamoDB Session Handler is a custom s

Strona 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.

Strona 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

Strona 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

Strona 49 - Modeled Responses

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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 55 - Modifying APC settings

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

Strona 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

Strona 57

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

Strona 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

Strona 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

Strona 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

Strona 61 - Auto Scaling

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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 68

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

Strona 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

Strona 70 - Amazon CloudSearch

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

Strona 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

Strona 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

Strona 73

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

Strona 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

Strona 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

Strona 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

Strona 77 - Creating tables

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

Strona 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

Strona 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

Strona 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

Strona 81

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

Strona 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

Strona 83

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

Strona 84 - Using the WriteRequestBatch

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

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

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

Strona 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

Strona 87

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

Strona 88

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

Strona 89

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

Strona 90

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

Strona 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

Strona 92

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

Strona 93

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

Strona 94 - Amazon ElastiCache

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

Strona 95

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

Strona 96 - AWS Elastic Beanstalk

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

Strona 97 - Elastic Load Balancing

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

Strona 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

Strona 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

Strona 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

Strona 101 - Amazon Glacier

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

Strona 102 - Creating a client

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

Strona 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

Strona 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

Strona 105 - Amazon Kinesis

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

Strona 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

Strona 107 - AWS OpsWorks

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

Strona 108

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

Strona 109

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

Strona 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

Strona 111 - Creating snapshots

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

Strona 112 - Amazon Route 53

DescribeTags DescribeTerminationPolicyTypesDisableMetricsCollection EnableMetricsCollectionExecutePolicy PutNotificationConfigurationPutScalingPolicy

Strona 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

Strona 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

Strona 115 - Uploading objects

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

Strona 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

Strona 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

Strona 118 - Saving objects to a file

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

Strona 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

Strona 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

Strona 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

Strona 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 =

Strona 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

Strona 124 - Amazon Simple Email Service

DescribeAlarms DescribeAlarmsForMetricDisableAlarmActions EnableAlarmActionsGetMetricStatistics ListMetricsPutMetricAlarm PutMetricDataSetAlarmStateAW

Strona 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

Strona 126 - Adding items

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

Strona 127 - Retrieving items

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

Strona 128 - Deleting domains

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

Strona 129

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

Strona 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

Strona 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

Strona 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

Strona 133

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

Strona 134 - AWS Security Token Service

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

Strona 135 - Using Temporary Credentials

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

Strona 136 - AWS Support

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

Strona 137

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

Strona 138

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

Strona 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

Strona 140 - Configuration

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

Strona 141

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

Strona 142 - Garbage Collection

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

Strona 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

Strona 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

Strona 145 - Other object functions

CancelConversionTask CancelExportTaskCancelReservedInstancesListing CancelSpotInstanceRequestsConfirmProductInstance CopyImageCopySnapshot CreateCusto

Strona 146 - Working with buckets

DescribeSnapshots DescribeSpotDatafeedSubscriptionDescribeSpotInstanceRequests DescribeSpotPriceHistoryDescribeSubnets DescribeTagsDescribeVolumeAttri

Strona 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-

Strona 148 - Service-Specific Guides

DescribeEvents DescribeReplicationGroupsDescribeReservedCacheNodes DescribeReservedCacheNodesOfferingsModifyCacheCluster ModifyCacheParameterGroupModi

Strona 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

Strona 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

Strona 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

Komentarze do niniejszej Instrukcji

Brak uwag