63
Takayuki Shimizu Solutions Architect, Amazon Data Services Japan, K.K. PHP カンファレンス 2015 2015. 5. 30 で始める AWS Mobile サービス

PHP で始める AWS モバイルサービス - PHPカンファレンス_20150530

Embed Size (px)

Citation preview

  1. 1. Takayuki Shimizu Solutions Architect, Amazon Data Services Japan, K.K. PHP 2015 2015. 5. 30 AWS Mobile
  2. 2. shimy.net Web AWS ( http://www.slideshare.net/shimy_net)
  3. 3. " AWS Mobile " AWS Mobile SDK AWS SDK for PHP " Amazon Cognito Identity () Sync " Amazon SNS Mobile Push "
  4. 4. " AWS Mobile " AWS Mobile SDK AWS SDK for PHP " Amazon Cognito Identity () Sync " Amazon SNS Mobile Push "
  5. 5.
  6. 6.
  7. 7.
  8. 8. ID ID . AWS Cloud
  9. 9. ID ID . AWS Cloud
  10. 10.
  11. 11.
  12. 12. AWS SDK for PHP
  13. 13. Identity Management & & & Data Pipelines Hadoop Real-time Streaming Data DevOps App Streaming E Workflow CDN (VMs, Auto-scaling & Load Balancing) (Relational, NoSQL, Caching) (VPC, DX, DNS) (Object, Block and Archival) Points of Presence E & AWS 40
  14. 14. AWS Mobile Amazon Cognito Kinesis DynamoDB S3 SQS SES AWS SDK for Android AWS Mobile SDK Amazon Mobile Analytics Amazon SNS Mobile Push AWS SDK for iOS AWS SDK for Unity Lambda Lambda Functions
  15. 15. AWS Mobile Amazon Cognito Kinesis DynamoDB S3 SQS SES AWS SDK for Android AWS Mobile SDK Amazon Mobile Analytics Amazon SNS Mobile Push AWS SDK for iOS AWS SDK for Unity Lambda Lambda Functions NoSQL , E
  16. 16. AWS Mobile Amazon Cognito Kinesis DynamoDB S3 SQS SES AWS SDK for Android AWS Mobile SDK Amazon Mobile Analytics Amazon SNS Mobile Push AWS SDK for iOS AWS SDK for Unity Lambda Lambda Functions NoSQL , E
  17. 17. AWS Mobile Amazon Cognito Kinesis DynamoDB S3 SQS SES AWS SDK for Android AWS Mobile SDK Amazon Mobile Analytics Amazon SNS Mobile Push AWS SDK for iOS AWS SDK for Unity Lambda Lambda Functions AWS SDK
  18. 18. " AWS Mobile " AWS Mobile SDK AWS SDK for PHP " Amazon Cognito Identity () Sync " Amazon SNS Mobile Push "
  19. 19. AWS Mobile SDK Android, Fire OS, iOS, Unity Amazon Cognito
  20. 20. AWS Mobile SDK for Unity (5/14 release) Unity AWS Unity 4.0 AWS Amazon Cognito Amazon S3 Amazon DynamoDB Amazon Mobile Analytics Coming Soon !
  21. 21. SDK IDE Android iOS Java NodeJS .NET PHP Python Ruby JavaScript in Browser Unity CLI Powershell IDE Eclipse Visual Studio SDK
  22. 22. 2 PHP AWS SDK for PHP version 3 - 2015.5.27 NEW AWS Promises
  23. 23. // Result $result = $s3Client->putObject([! 'Bucket' => 'your-bucket',! 'Key' => 'docs/file.pdf',! 'Body' => fopen('/path/to/file.pdf', 'r'),! ]);! ! // Result echo $result['ObjectURL'];! // Promise $promise = $s3Client->putObjectAsync([! 'Bucket' => 'your-bucket',! 'Key' => 'docs/file.pdf',! 'Body' => fopen('/path/to/file.pdf', 'r'),! ]);! ! // Result $result = $promise->wait();! ! // Result echo $result['ObjectURL'];! NEW
  24. 24. DynamoDB $client->createTableAsync([! 'TableName' => $table,! // Other params...! ])->then(function () use ($client, $table) {! return $client->getWaiter('TableExists', [! 'TableName' => $table,! ])->promise();! })->then(function () use ($client, $table) {! return $client->putItemAsync([! 'TableName' => $table,! 'Item' => [! // Item attributes...! ]! ]);! })->wait();! DynamoDBNoSQL Waiters ACTIVE Promise then()
  25. 25. " AWS Mobile " AWS Mobile SDK AWS SDK for PHP " Amazon Cognito Identity () Sync " Amazon SNS Mobile Push "
  26. 26. Amazon Cognito
  27. 27. Amazon Cognito ID Guest
  28. 28. ID ID AWS ID Username Password ID ID Amazon, Facebook, Twitter, Google, OpenID Connect AWS ID Amazon Cognito Identity Mobile Analytics S3DynamoDBKinesis
  29. 29. DynamoDB Amazon Cognito Identity Cognito ID Temp Credentials S3 Access Token Pool ID Role ARNs Temp Credentials Mobile SDK ID Kinesis Cognito ID AWS Amazon Cognito Identity
  30. 30. IAM AWS AWS Credentials AWS EC2S3DynamoDBKinesis S3 DynamoDB Get Delete Put
  31. 31. Developer Authenticated Identities DynamoDB Amazon Cognito Identity1. Login 4. OpenID Token 6. Cognito ID Temp Credentials S3 5. OpenID Token Pool ID Role ARNs 7. Temp Credentials Mobile SDK Analytics 2. GetOpenIDTokenForDeveloperIdentity() 3. OpenID Token ID UsernamePassword AWS PHP
  32. 32. Developer Authenticated Identities DynamoDB Amazon Cognito Identity1. Login 4. OpenID Token 6. Cognito ID Temp Credentials S3 5. OpenID Token Pool ID Role ARNs 7. Temp Credentials Mobile SDK Analytics 2. GetOpenIDTokenForDeveloperIdentity() 3. OpenID Token ID UsernamePassword AWS PHP
  33. 33. GetOpenIdTokenForDeveloperIdentity // Cognito Token $result = $client->getOpenIdTokenForDeveloperIdentity(array(! 'IdentityPoolId' => 'string',! 'IdentityId' => 'string',! 'Logins' => array(! 'IdentityProviderName' => 'string',! ), ! 'TokenDuration' => integer, ! ));! Returns GuzzleServiceResourceModel IdentityId => (string)! Token => (string)!
  34. 34. Amazon Cognito ID Guest
  35. 35. Amazon Cognito Sync User Data Storage and Sync Any Platform iOS/Android/FireOS k/v data Identity pool 20MB 1MB Key/Value 1024 Key Base64
  36. 36. SDK Amazon Cognito Sync
  37. 37. Amazon Cognito Sync Amazon Cognito Identity Mobile SDK Amazon Cognito Sync Store 3. Dataset Amazon Cognito Sync Amazon Cognito Cognito ID Amazon Cognito Sync Store 2. Cognito ID Temp Credentials 1. Access Token Pool ID Role ARNs
  38. 38. AWS Account Dataset Identity Identity Identity Dataset Dataset Identity Pool 1:n 1:n 1:n Dataset Dataset DatasetDataset Key/Value 1:n Amazon Cognito Sync
  39. 39. () Mobile SDK Amazon Cognito Sync Store 1. () Mobile SDK Amazon SNS Mobile Push 2. 3. Amazon SNS Mobile Push Amazon Cognito Amazon SNS Mobile Push Amazon Cognito Push Sync
  40. 40. Amazon Kinesis Amazon Cognito Amazon Kinesis Mobile SDK Amazon Cognito Sync Store 1. Amazon Kinesis 2. Stream Content 3. Amazon Redshift {! "identityPoolId" : "Pool Id! "identityId" : "Identity Id ! "dataSetName" : "Dataset Name! "operation" : "(replace|remove)! "kinesisSyncRecords" : [! {! "key" : "Key",! "value" : "Value",! "syncCount" : 1,! "lastModifiedDate" : 1424801824343,! "deviceLastModifiedDate" : 1424801824343,! "op": "(replace|remove)" }, ...! ],! "lastModifiedDate": 1424801824343,! "kinesisSyncRecordsURL": "S3Url",! "payloadType" : "(S3Url|Inline)",! "syncCount" : 1 ! }! Amazon Cognito Stream
  41. 41. Mobile SDK Amazon Cognito Sync Store 1. AWS Lambda 2. Sync Trigger Amazon Lambda 3. Amazon Cognito Events Key Value Key Value Lambda Function (Node.js)
  42. 42. Amazon Cognito Sync Android CognitoSyncManager Dataset Key Values cognito = new CognitoSyncManager (context,! Regions.US_EAST_1, provider);! dataset.synchronize(new SyncCallback(){..});! Dataset dataset = ! cognito.openOrCreateDataset(datasetName);! dataset.put(key, value);!
  43. 43. " AWS Mobile " AWS Mobile SDK AWS SDK for PHP " Amazon Cognito Identity () Sync " Amazon SNS Mobile Push "
  44. 44. Amazon SNS Mobile Push
  45. 45. (e.g. Apple, Google, Amazon)
  46. 46. API Apple APNS Google GCM Amazon ADM
  47. 47.
  48. 48. Amazon SNS Mobile Push
  49. 49. Amazon SNS Mobile Push Amazon SNS Mobile Push Apple iOS Google Android Amazon Kindle Fire Baidu Android MS Windows Phone
  50. 50. API 1. 2. 3. 4. (Create Platform Endpoint) 5. EndpointArn 6. EndpointArn Mobile Push Database Web ELB PHP
  51. 51. API 1. 2. 3. 4. (Create Platform Endpoint) 5. EndpointArn 6. EndpointArn Mobile Push Database Web ELB PHP
  52. 52. Endpoint $result = $client->createPlatformEndpoint(array(! 'PlatformApplicationArn' => 'string',! 'Token' => 'string',! 'CustomUserData' => 'string',! 'Attributes' => array(! 'String' => 'string',! ), ! ));!
  53. 53. 5. 2. EndpointArn Mobile Push 1. Web Database ELB Worker 3. Publish4. PHP
  54. 54. 5. 2. EndpointArn Mobile Push 1. Web Database ELB Worker 3. Publish4. PHP
  55. 55. Endpoint $result = $client->publish(array(! 'TopicArn' => 'string',! 'TargetArn' => 'string',! 'Message' => 'string',! 'Subject' => 'string',! 'MessageStructure' => 'string',! 'MessageAttributes' => array(! 'String' => array( ! 'DataType' => 'string',! 'StringValue' => 'string',! 'BinaryValue' => 'string', ! ),! ), ! ));!
  56. 56. Amazon Cognito 12 100 10 GB 10000 $0.15 $0.15 / GB Amazon SNS Mobile Push 12 100 100 $1
  57. 57. " AWS Mobile " AWS Mobile SDK AWS SDK for PHP " Amazon Cognito Identity () Sync " Amazon SNS Mobile Push "
  58. 58. AWS Amazon Cognito (Identity) AWS Identity and Access Management Amazon Cognito (Sync) Amazon Mobile Analytics AWS Lambda Amazon CloudFront (Device Detection) Amazon DynamoDB (Object Mapper) Amazon Kinesis (Recorder) Amazon SNS Mobile Push AWS Mobile SDK Amazon S3 Transfer Manager
  59. 59. AWS ID ID . AWS Cloud
  60. 60. AWS ID ID . AWS Cloud