Movatterモバイル変換


[0]ホーム

URL:


PDF, PPTX9,581 views

[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-

Embed presentation

Download as PDF, PPTX
re:GenerateAWSマイスターシリーズ  AWS  Client-‐‑‒side  SDK-‐‑‒  Android,  iOS  and  Javascript  -‐‑‒2014.2.5ソリューションアーキテクト安川  健太    今井  雄太© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Agenda!   AWS  SDK  オーバービュー!   クライアント側SDKの活⽤用法!   クライアント側SDKにおけるAWS  Credentialsの取り扱い!   各クライアント側SDKの紹介•  AWS  SDK  for  Android•  AWS  SDK  for  iOS•  AWS  SDK  for  JavaScript  in  the  Browser!   まとめ© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  オーバービュー© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWSのサービス操作と⾔言えばAWS  Management  ConsoleAWSコマンドラインツール© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
これらの裏裏側では・・・!     各サービスの各操作にAPIが定義されている!   AWSでは・・・•  ⼈人間がGUIまたはCUI越しに叩く•  プログラミングしてそれを⾃自動化・簡易易化・カスタマイズ•  ⼈人間が⼿手でやらなくてはいけない事をプログラミングして⾃自動化できる、これがSDKで簡単に実現可能à  AWSの実は最も優れた⼀一⾯面© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDKとは!   AWSのサービスをプログラムで操作できるSDK•  さまざまな⾔言語で• • • • • • • • • • AWS  SDK  for  JavaAWS  SDK  for  .NetAWS  SDK  for  RubyAWS  SDK  for  PHPAWS  SDK  for  Python  (boto)AWS  SDK  for  node.jsAWS  SDK  for  AndroidAWS  SDK  for  iOSAWS  SDK  for  Javascript  in  Browser有志の⽅方による実装(ActionScript)も•  通信は原則HTTPS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
SDK⼀一般の動作イメージ起動、停⽌止RESTAWS  SDKSOAPPut,GetDB起動バックアップ認証情報情報取得© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDKをある観点でざっくり分けると開発者の環境(サーバやバッチ処理理ワーカーなど)で動かすコードで利利⽤用JavanodeJS.NETPHPPythonRubyエンドユーザの端末あるいはサービスのクライアント側で動くコードで利利⽤用AndroidiOSJavascriptin  Browserクライアント側SDK© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
クライアント側SDKの活⽤用法© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWSのマネージドサービスを活⽤用した2-‐‑‒tierのアーキテクチャが組める!   モバイル端末やブラウザからAWSの各種サービスを呼ぶ•  AWSのマネージドサービスを組み合わせてバックエンドに•  しかもプラットフォーム横断で連携!© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
例例1:静的ファイルだけで動的サイト! DynamoDBやS3などをデータの保存先とするHTML+JSをS3に置けばWebサーバ無しで動的サイトを構築可データの読み書きHTML+JShttps://s3.amazonaws.com/aws.mattgy.net/dynamodb-‐‑‒d3/index.html© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
例例2:  モバイルアプリ間でメッセージング!   AWSサービスのみで作るチャットアプリ•  サーバ側のコーディングなしで掲⽰示板/チャットサービスを提供DynamoDB・メッセージの保存・チャットグループとメッセージの紐紐付Simple  Notification  Service  (SNS)・新規メッセージの通知Simple  Queue  Service  (SQS)・SNSの通知受け⼝口Simple  Storage  Service  (S3)・画像等のデータの保存先・配信元© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
例例2:  モバイルアプリ間でメッセージング! DynamoDB,  S3を使ってデータ共有2.  DBクエリ  /  ファイルリクエストDynamoDB1.  DB書き込み  /  ファイルアップロード3.  DB応答  /  ファイルダウンロードS3© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
例例2:  モバイルアプリ間でメッセージング!   SNSとSQSを使ってPub/SubSNS:  Simple  Notification  ServiceSQS:  Simple  Queue  Service+SNS  topicSQS  queue2.  Notify1.  Publish© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
例例2:  モバイルアプリ間でメッセージングチャットグループへのSubscribe!   過去メッセージはDynamoDBから取得!   SQSでキューを作成し、SNSにSubscribe1.  SQSのキューを作成チャットグループのSNSトピック2.  SNSトピックにSubscribe4.  SNSトピックにPublish5.  SQSを通じて通知クライアントA0.  メッセージ⼀一覧取得クライアントB3.  新メッセージ書き込み© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
例例2:  モバイルアプリ間でメッセージングチャットグループへのファイルアップロード!   S3にファイルをアップロード!   SNSで通知チャットグループのSNSトピック3.  SNSトピックにPublish4.  SQSを通じて通知クライアントA5.  ファイルダウンロード2.  メッセージ書き込みクライアントB1.  ファイルアップロード© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
その他の例例⾮非同期バッチ処理理!   ⾮非同期バッチ処理理要求を直接登録•  通常のWebアプリ等Job  queueClientWorkersWeb  Frontend•  Android/iOS/Javascript  SDKを使った場合Job  queueWorkers© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
その他の例例ログやイベント情報の集計処理理!   ログやイベント情報を直接登録•  通常のWebアプリ等ClientWeb  Frontendログ・イベント集計•  Android/iOS/Javascript  SDKを使った場合ログ・イベント集計© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Amazon  SNSへのデバイストークンの登録も直接可能Apple  DevicesGoogle  Devicesント・3.  エンドポイユーザ情報登録2.  エンドポイントAmazon  Kindle  Fire  Devicesエンドポイント取得Push通知Amazon  SNSMobile  Push© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
クライアント側SDK活⽤用のメリット!   アプリの開発に多くのメリット:• • • • バックエンド側の開発コストを最⼩小化バックエンド側の運⽤用コストを最⼩小化スケーラビリティの⼼心配なし⾦金金額⾯面でもローコスト(当社⽐比*)!   必要に応じてEC2も導⼊入できる安⼼心感•  後からバックエンド側にロジックを⼊入れてシステムの最適化*  EC2で同規模のサーバを⽴立立てる場合に⽐比べ© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  CREDENTIALSの取扱い© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
誰のAWSアカウントを使う?!   AWSのコンソールアプリを作る場合•  エンドユーザはAWSユーザàAWSのアクセスキーとシークレットキーを⼊入⼒力力してもらえばOK!   AWSの各種サービスを使ったアプリを作る場合•  AWSの各種サービスはあくまでバックエンド•  エンドユーザは必ずしもAWSユーザではないàアプリは開発者のアカウントで認証・認可を受ける必要© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
開発者アカウントを使うとして…!   アプリに開発者アカウントのアクセスキー等を埋め込んだら•  アクセスキーが広範にばら撒かれることに•  アクセスキーの不不正利利⽤用を⽌止めるためにキーを無効化したらà全ユーザへのサービスが停⽌止!!!   アクセスキーの定期的な更更新で対処するにしても•  更更新のたびにバージョンアップは⾮非現実的•  更更新前のアプリからはサービス利利⽤用不不可に© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
セキュアなAWSアクセスを提供するには!   アプリに認証情報を埋め込むべきではない!   エンドユーザ/端末ごとに異異なるCredentialsを提供すべき•  ユーザごとに必要最⼩小限の権限を与えるのは重要•  不不正利利⽤用発覚時に不不正ユーザのみ権限を停⽌止!   Credentialsは期限が来たら無効化されるべき•  不不正ユーザの影響も期限付きにこれを実現する仕組みあります!© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Security  Token  Service!   AWSに対する、⼀一時的な認証情報を作成する仕組み•  期限付きの認証情報(認証チケット)を発⾏行行•  Identity  and  Access  Management  (IAM)サービスの機能!   ユーザーに対して、以下の3つのキーを発⾏行行§  アクセスID§  シークレットキー§  セッショントークン!   作成した認証情報の有効期限設定が可能§  デフォルト12時間  最⼩小1時間  最⼤大36時間§  ただし延⻑⾧長・短縮は出来ない但し、STS⾃自体は認証の機能を持たないため、認証の仕組みは別途必要© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
認証機構とSTSとをインテグレーションする際の選択肢{Facebook,  Google,  Amazon}  のIDで認証YesWeb  Identity  Federationを利利⽤用可!YesIdentity  TVMが選択肢にNo独⾃自の認証付きToken  Vending  Machine  (TVM)実装が必要ユーザごとに異異なる権限を与える必要ありNoAnonymous  TVMが選択肢に© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Web Identity Federation!   Web Identity Providerの認証結果を受けてAWSの各種サービスへのアクセスを認可する仕組み!   IAM RoleのAssume機能を利用して実現•  Web Identity Providerによって認証されたユーザは特定のIAM Roleを持つものと見なす(Assume)する!   対応Identity Providerは•  Facebook•  Google•  Amazon© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Web  Identity  Federationの動作フローSTS⾃自体が認証済みユーザにアクセストークンを発⾏行行するToken  Vending  Machine  (TVM)の役割を担っている詳細はマイスターシリーズIAM回を参照:  http://www.slideshare.net/AmazonWebServicesJapan/20130716-‐‑‒aws-‐‑‒meisterregenerateiampublic© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Web  Identity  Federation利利⽤用時のコード例例!   AndroidWebIdentityFederationSessionCredentialsProvider  wif  =                  new  WebIdentityFederationSessionCredentialsProvider(fbSession.getAccessToken(),                                                                                                                          "graph.facebook.com",                                                                                                                          ROLE_̲ARN);String  subjectFromWIF  =  wif.getSubjectFromWIF();  s3  =  new  AmazonS3Client(wif);!iOSAmazonWIFCredentialsProvider  *wif  =  [[AmazonWIFCredentialsProvider  alloc]initWithRole:ROLE_̲ARNandWebIdentityToken:self.session.accessTokenData.accessToken                                                                fromProvider:@"graph.facebook.com"];NSString  *subjectFromWIF  =  wif.subjectFromWIF;s3  =  [[[AmazonS3Client  alloc]  autorelease]  initWithCredentialsProvider:wif];© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
独⾃自の認証機構を⽤用いる場合Token  Vending  Machine  (TVM)を導⼊入•  ユーザ/端末の認証とトークンの発⾏行行を実施•  アプリケーションごとの認証とSTSを結びつけるための仕組み1.  Security  Token  Serviceから認証トークンを取得1  STSから2.  クライアントに認証トークンを提供3.  クライアントは認証トークンを⽤用いてAWSにアクセス3アプリの認証機構に合わせて任意の実装12© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
TVMの実装⽅方針を⼤大別すると! AnonymousTVM•  ユーザ認証を必要とせず、⼀一時認証トークンの機能のみ利利⽤用したいユースケース向け•  例例:誰でも参加出来る掲⽰示板システム、ログの記録! IdentityTVM•  ユーザ認証を実施し、認証されたユーザにのみ認証トークンを発⾏行行するユースケース向け•  例例:ユーザ認証を伴うソーシャルアプリ、ゲーム等どちらもサンプルの実装がサーバ側・クライアント側とも公開されている© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Anonymous  TVM!   デバイス固有のIDと対応する秘密鍵をTVMに登録!   秘密鍵を使って認証トークンを暗号化して提供デバイス固有のIDと秘密鍵を登録秘密鍵を使って© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Identity  TVM!!!!    Facebook,  Twitter,Out-‐‑‒of-‐‑‒bandでユーザ登録LDAPやAD等の基幹システムによる認証で置き換え可登録したユーザ情報でログイン処理理TVM⽤用秘密鍵の共有秘密鍵を使って認証トークンを暗号化して提供Anonymousの場合と同様ユーザのパスワードで暗号化© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Web  Identityを⽤用いたFine  Grained  Access  Control!   例例1:  S3バケット内にユーザごとのプライベートな領領域を作成{  "Version":"2012-‐‑‒10-‐‑‒17",      "Statement":[      {  "Effect":"Allow",        "Action":["s3:GetObject",  "s3:PutObject",  "s3:DeleteObject"],          "Resource":[                "arn:aws:s3:::myBucket/myApp/${graph.facebook.com:id}",                  "arn:aws:s3:::myBucket/myApp/${graph.facebook.com:id}/*“          ]    }  ]Facebookにログインした}ユーザーのIDが⼊入る© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Web  Identityを⽤用いたFine  Grained  Access  Control!   例例2:  DynamoDBのテーブル内にユーザごとにプライベートな⾏行行/列列を定義する  "Condition":  {                "ForAllValues:StringEquals":  {                    "dynamodb:LeadingKeys":  [                        "${www.amazon.com:user_̲id}"                    ],                    "dynamodb:Attributes":  [                        "UserId”,"GameTitle”,  "Wins”,  "Losses”                    ]                },                "StringEqualsIfExists":  {                    "dynamodb:Select":  "SPECIFIC_̲ATTRIBUTES"                }            }© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
各クライアント側SDKの紹介© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  FOR  ANDROID© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  for  Androidとは!   Amazon提供のAWS開発⽤用のAndroid向けSDK!   公式ページ:http://aws.amazon.com/jp/sdkforandroid/!   環境:Android  2.3  (API  level  10)以上!   利利⽤用⽅方法•  公式ページからダウンロード•  GitレポジトリからMavenをお使いの場合:公式MavenレポジトリLocalレポジトリにインストールしての利利⽤用は可(但し、正式サポートの範囲外)© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
操作可能サービスEC2S3DynamoDBSimpleDBSNSSQSSESELBCloudWatchAutoscaling※サポートするサービスの範囲はiOS  SDKと同様© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
SDKに含まれるもの!   AWS  Android  ライブラリ•  各種サービス向けAPIを提供するJavaライブラリ•  Androidアプリのプロジェクトから参照•  最終的にはAPKに内包!   ソースコード!   ドキュメント(コードサンプルはGitレポジトリに移動)https://github.com/awslabs/aws-‐‑‒sdk-‐‑‒android-‐‑‒samples• • • • • • 各種サービスの操作SNSとSQSを使ったメッセージボードS3アップローダSimpleDB  ハイスコアSESフィードバックフォームDynamoDBを使ったユーザプリファレンス© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
初期設定!   プロジェクトの依存関係にAndroid  SDKを追加•  EclipseとAndroid  SDKを使っている場合の例例:必要なライブラリをプロジェクトのlibs配下にコピー注:他の場所に配置する場合は最終的なAPKにクラスファイルが含まれるようにすること© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
依存するJarファイルについてTips!   開発時はデバッグシンボル付きのライブラリを使⽤用aws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒debug.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒ddb-‐‑‒mapper-‐‑‒debug.jar!   配布時は必要なサービスのみ同梱全部⼊入りaws-‐‑‒android-‐‑‒sdk-‐‑‒<version>.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒ddb-‐‑‒mapper.jarDynamoDBMapperを使う場合に必要必要なサービスのみaws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒core.jar        +      aws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒ddb.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒s3.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒sns.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒sqs.jarあるいはproguardを使って必要なパッケージのみ同梱© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例!   基本的な流流れ(iOSも同様)• • • • 利利⽤用するサービスのクライアントオブジェクトの作成サービスのリクエストオブジェクトを作成クライアントオブジェクトを通じてリクエストレスポンスを受け取るS3にファイルをアップロードする例例void  uploadToS3  (String  bucketName,  String  objectName,  File  file){      AmazonCredentials  credentials  =  new  BasicAmazonCredentials(ACCESS_̲KEY,  SECRET_̲KEY);      AmazonS3Client  s3  =  new  AmazonS3Client(credentials);      PutObjectRequest  req  =  new  PutObjectRequest(bucketName,  objectName,  file));      PutObjectResponse  resp  =  s3.putObject(req);}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:S3へのアップロード  (⾮非同期)S3UploadTask  uploadTask  =  new  S3UploadTask();uploadTask.execute(new  PutObjectRequest(bucketName,  objectName,  tempFile));private  class  S3UploadTask  extends  AsyncTask<PutObjectRequest,  Long,  Long>  implements  ProgressListener  {protected  Long  totalSent;バックグラウンド実⾏行行//  AsyncTask#doInBackground()protected  Long  doInBackground  (PutObjectRequest...  reqs)  {totalSent  =  0L;reqs[0].setProgressListener(this);S3.getInstance().putObject(reqs[0]);return  totalSent;}  //  ProgressListener#progressChanged()進⾏行行状 public  void  progressChanged  (ProgressEvent  progressEvent)  { totalSent  +=  progressEvent.getBytesTransfered();publishProgress(totalSent);況の更更}新}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:DynamoDBへのQueryハッシュキーとレンジキーのMaxを指定して特定のテーブルにクエリを送る例QueryResult doQuery (String hashKey, String max) {ハッシュキーを AttributeValue hashKey = new AttributeValue().withS(hashKey);指定Condition lessThanMax = new Condition().withComparisonOperator(ComparisonOperator.LT)条件を.withAttributeValueList(new AttributeValue().withN(max));指定QueryResult result = dynamoClient.query(new QueryRequest().withTableName(TABLE_NAME)クエリを.withLimit(NUMBER_OF_ITEMS_TO_GET_AT_ONCE)実行.withHashKeyValue(hashKey).withRangeKeyCondition(lessThanMax));return result;}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:DynamoDBMapperでDynamoDBにオブジェクトを永続化POJOを定義@DynamoDBTable(tableName = “meisters_items”)public class MeistersItem {private String id;private long value;@DynamoDBHashKey(attributeName = “id”)public String getId() {return id;}@DynamoDBHashKey(attributeName = “id”)public void setId(String id) {this.id = id;}@DynamoDBAttribute(attributeName = “value”)public long getValue() {return time;}}DynamoDBMapperを初期化AmazonDynamoDBClient dynamoClient =new AmazonDynamoDBClient(getCredentials());AmazonDynamoDBMapper dbMapper =new DynamoDBMapper(getDynamoClient());POJOの保存MeisterItem item = new MeisterItem();item.setId(“Expensive item”);item.setValue(10000);dbMapper.save(item);POJOの読み込みMeisterItem item = dbMapper.load(MeisterItem.class,“Expensive item”);@DynamoDBAttribute(attributeName = “value”)public void setValue(long time) {this.time = time;}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
Android  SDK利利⽤用時のTips!   UIスレッドからAWSのAPIを呼ぶのは避ける•  適宜AsyncTaskや別Threadを使⽤用!   各サービスクライアントのインスタンスは再利利⽤用•  サービスクライアントの実装はThread  Safe•  Singletonにすることで重いオブジェクト⽣生成を最⼩小限に•  例例:サンプル内のAmazonClientManagerpublic  class  AmazonClientManager  {  //  下記コードは簡易易版        private  AmazonS3Client  s3Client  =  null;        public  AmazonS3Client  s3()  {                if  (s3Client  ==  null)  s3Client  =  new  AmazonS3Client(  credentials  );                return  s3Client;        }  }!   ユースケース別の解説付きコードサンプルがこちらに:•  http://aws.amazon.com/articles/SDKs/Android© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  FOR  IOS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  for  iOSとは!   Amazon提供のAWS開発⽤用iOS  SDK!   公式ページ:http://aws.amazon.com/jp/sdkforios/!   動作環境:iOS  4.3以上  !   開発環境:Xcode  v4以上!   利利⽤用⽅方法•  公式ページからダウンロード•  Gitレポジトリから© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
操作可能サービスEC2S3DynamoDBSimpleDBSNSSQSSESELBCloudWatchAutoscaling※サポートするサービスの範囲はAndroid  SDKと同様© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
SDKに含まれるもの!   AWS  iOSライブラリ•  各種サービス向けAPIを提供するObjective-‐‑‒Cライブラリ•  iOSアプリプロジェクトのフレームワークの1つとして参照!   ドキュメント!   ソースコード(コードサンプルはGitレポジトリに移動)https://github.com/awslabs/aws-‐‑‒sdk-‐‑‒ios-‐‑‒samples• • • • • • • 各種サービスの操作SNSとSQSを使ったメッセージボードS3アップローダSimpleDB  ハイスコアSESフィードバックフォームDynamoDBを使ったユーザプリファレンスDynamoDB  を  CoreDataフレームワークのバックエンドに© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
初期設定  〜~Frameworkの追加〜~!   プロジェクトにSDKを追加1.  Xcodeにてプロジェクトを開く2.  Frameworks  GroupをCtrlを押しながらクリック3.  AWSiOSSDK.frameworkを追加• AWSPersistence.frameworkは任意(DynamoDB  +  CoreDataを使ったPersistenceを利利⽤用する場合)4.  ソースコードで必要なヘッダファイルをインクルード•  例例#import  <AWSiOSSDK/S3/AmazonS3Client.h>#import  <AWSiOSSDK/SimpleDB/AmazonSimpleDBClient.h>#import  <AWSiOSSDK/SQS/AmazonSQSClient.h>#import  <AWSiOSSDK/SNS/AmazonSNSClient.h>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
初期設定  〜~ドキュメントのインストール〜~!   ドキュメントセットをXcodeにインストール• SDKのディレクトリからdocsetファイルをコピー• これを  – • Documentation/com.amazon.aws.ios.docsetここに  – $HOME/Library/Developer/Shared/Documentaion/DocSets$  mkdir  –p  $HOME/Library/Developer/Shared/Documentaion/DocSets$  cp  Documentation/com.amazon.aws.ios.docset  $HOME/Library/Developer/Shared/Documentaion/DocSets• Xcodeを再起動© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例!   基本的な流流れ  (Androidも同様)• • • • 利利⽤用するサービスのクライアントオブジェクトの作成サービスのリクエストオブジェクトを作成クライアントオブジェクトを通じてリクエストレスポンスを受け取るS3にファイルをアップロードする例例-‐‑‒  void  uploadToS3:  (NSString*)  bucketName  keyName:  (NSString  *)  keyName  fileName:  (NSString  *)  fileName  {      S3PutObjectRequest  *putObjectRequest  =                [[[S3PutObjectRequest  alloc]  initWithKey:keyName  inBucket:bucketName]  autorelease];        putObjectRequest.filename  =  fileName;        [[AmazonClientManager  s3]  putObject:putObjectRequest];}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:S3へのアップロード(⾮非同期)1/2  NSOperationのサブクラスとしてS3 Uploaderを実装#import <Foundation/Foundation.h>#import <AWSiOSSDK/AmazonServiceRequest.h>@interface AsyncImageUploader:NSOperation<AmazonServiceRequestDelegate>{…- (void) start {….// Puts the file as an object in the bucket.S3PutObjectRequest *putObjectRequest =[[[S3PutObjectRequest alloc] initWithKey:keyName inBucket:bucketName] autorelease];putObjectRequest.filename = filename;Delegateとして途中経過や結果を受けputObjectRequest.delegate = self;取れるように登録[[AmazonClientManager s3] putObject:putObjectRequest];}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:S3へのアップロード(⾮非同期)2/2  Delegateパターンで途中経過や結果を受け取り完了時の処理-(void) request:(AmazonServiceRequest *)requestdidCompleteWithResponse:(AmazonServiceResponse *)response{[self performSelectorOnMainThread:@selector(hideProgressView)withObject:nil waitUntilDone:NO];[self finish];}進行状況の更新処理-(void) request:(AmazonServiceRequest *)requestdidSendData:(NSInteger)bytesWrittentotalBytesWritten:(NSInteger) totalBytesWrittentotalBytesExpectedToWrite:(NSInteger) totalBytesExpectedToWrite{[self performSelectorOnMainThread:@selector(updateProgressView:)withObject:[NSNumber numberWithFloat: (float)totalBytesWritten / totalBytesExpectedToWrite] waitUntilDone:NO];}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:DynamoDBへのQuery-(DynamoDynamoDBQueryResponse *) doQuery: (NSString*) hashKeymax: (NSString *) max {DynamoDBQueryRequest *req = [[DynamoDBQueryRequest alloc] autorelease];req.tableName = TABLE_NAME;ハッシュ req.limit = [[NSNumber alloc] initWithInt: NUMBER_OF_ITEMS_TO_GET_AT_ONCE];キーを req.hashKeyValue = [[DynamoDBAttributeValue alloc] initWithS: hashKey] autorelease];指定DynamoDBCondition *lessThanMax = [[DynamoDBCondition alloc] autorelease];[req.rangeKeyCondition setComparisonOperator: @“LT"];[req.rangeKeyCondition addAttributeValueList:[[[DynamoDBAttributeValue alloc] initWithN: max] autorelease]];req.rangeKeyCondition = lessThanMax;条件を指定クエリをDynamoDBQueryResponse *resp = [[AmazonClientManager dynamodb] query: req];実行return resp;}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
iOS  SDK利利⽤用時のTips!   UIスレッドからAWSのAPIを呼ぶのは避ける•  適宜NSOperationやGCD等を使⽤用!   各サービスクライアントのインスタンスは再利利⽤用•  サービスクライアントの実装はThread  Safe•  例例:サンプル内のAmazonClientManager#import  "AmazonClientManager.h"static  AmazonS3Client              *s3    =  nil;@implementation  AmazonClientManager+(AmazonS3Client  *)s3{        if(s3  ==  nil)  s3    =  [[AmazonS3Client  alloc]  initWithCredentials:credentials];        return  s3;}!   ユースケース別の解説付きコードサンプルがこちらに:•  http://aws.amazon.com/articles/SDKs/iOS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  FOR  JAVASCRIPT  IN  WEB  BROWSER© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS  SDK  for  JavaScript  in  the  Browserとは!   Amazon提供のブラウザで動作するJavaScript環境のためのAWS  SDK•  node.js環境のためのSDKは別に存在する!   公式ページ:http://aws.amazon.com/jp/sdkforbrowser/!   環境:!   利利⽤用⽅方法•  公式ページからダウンロード•  Gitレポジトリから© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
操作可能サービスDynamoDBS3SQSSNS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
初期設定(1/2)!   HTML内にJavaScriptを読み込む•  SDKをインターネット上の任意の場所に配置し、Scriptタグで読み込む•  <script  type="text/javascript"  src=”PATH/TO/YOUR/SDK"></script>•  AWSで⽤用意するCDN上に配置されたSDKを使う•  <script  type="text/javascript"  src="https://sdk.amazonaws.com/js/aws-‐‑‒sdk-‐‑‒2.0.0-‐‑‒rc1.min.js"></script>!   読み込まれると、“AWS”というグローバル変数が利利⽤用可能になる© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
初期設定(2/2)! WebIdentityFederationでAWS  Credentialを取得//  FacebookのAccessTokenを使ってAWSのCredentialを取得するwindow.fbAsyncInit  =  function()  {                FB.init({  appId:  appId  });                FB.login(function(response)  {                    AWS.config.credentials  =  new  AWS.WebIdentityCredentials({                        ProviderId:  'graph.facebook.com',                        RoleArn:  roleArn,        //  IAM  RoleのARN                        WebIdentityToken:  response.authResponse.accessToken                    });                    fbUserId  =  response.authResponse.userID;                    button.style.display  =  'block';                });};//  FacebookのSDK読み込み(function(d,  s,  id){        var  js,  fjs  =  d.getElementsByTagName(s)[0];        if  (d.getElementById(id))  {return;}        js  =  d.createElement(s);  js.id  =  id;        js.src  =  "//connect.facebook.net/en_̲US/all.js";        fjs.parentNode.insertBefore(js,  fjs);}(document,  'script',  'facebook-‐‑‒jssdk')); be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not
コード例例:S3へのアップロード<input  type="file"  id="file-‐‑‒chooser"  /><button  id="upload-‐‑‒button"  style="display:  none”>Upload  to  S3</button><script  type="text/javascript”>//AWS.config.credentialにCredentialが取得済みの状態でvar  bucket  =  new  AWS.S3({params:  {Bucket:  “YOUR_̲BUCKET_̲NAME”}});button.addEventListener('click',  function()  {                var  file  =  fileChooser.files[0];                if  (file)  {                    results.innerHTML  =  '';                    var  objKey  =  “KEY_̲NAME”;                    var  params  =  {Key:  objKey,  Body:  file,  ACL:  'public-‐‑‒read'};                    bucket.putObject(params,  function  (err,  data)  {                        if  (err)  {                            console.log(err);                        }  else  {                            console.log(data);                        }                    });              }},  false);</script>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
コード例例:DynamoDBへのputItem<button  id="upload-‐‑‒button"  style="display:  none">Put  to  DynamoDB</button><script  type="text/javascript”>//AWS.config.credentialにCredentialが取得済みの状態でvar  dynamodb  =  new  AWS.DynamoDB({region:'ap-‐‑‒northeast-‐‑‒1'});button.addEventListener('click',  function()  {          var  params  =  {                      TableName:  'test',                                Item:  {                                        'title':  {S:  appId  +  'aaa'},                                        'message':  {S:  'Good  Morning'}                    }          };        dynamodb.putItem(params,  function(err,  data)  {                    if  (err)  {                                        console.log(err);                    }else{                                        console.log(data);                    }          });},  false);</script>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
まとめ© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
まとめ!   クライアント側SDKを⽤用いて2-‐‑‒tierアーキテクチャを実現• • • • バックエンド側の開発コストを最⼩小化バックエンド側の運⽤用コストを最⼩小化スケーラビリティの⼼心配なし⾦金金額⾯面でもコスト削減に!   Web  Identity  Federationや認証トークン機構を使うことでクライアントアプリからのAWSへのアクセスも安⼼心!   AWSはコーディングする⽅方の⼒力力を最⼤大限に引き出すインフラ•  その恩恵はサーバ側だけでなくクライアントアプリにも!•  HAPPY  CODING!!© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
ご参加ありがとうございました© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
TVM導⼊入の流流れ!   認証トークンに割り当てるユーザ権限を設定•  Identity  and  Access  Management  (IAM)でユーザを作成•  アプリケーションに合わせたポリシーを割り当て!   TVMを実装し、デプロイ•  サンプルはWARファイルをデプロイするだけで実⾏行行可•  AnonymousTVM•  IdentityTVMàElasticBeanstalkを使うと簡単!!   TVMの各種設定•  Security  Token  Serviceにアクセスするためのアクセスキー設定•  SSLの設定(推奨)© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
認証トークンに割り当てるユーザ権限を設定(1/2)!   IAMでTVM⽤用の新しいユーザを作成(例例:TVMUser)!   認証情報(アクセスキー・シークレットキー)を保存後でTVMアプリケーション側に設定するので大切に保存© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
認証トークンに割り当てるユーザ権限を設定(2/2)!   カスタムポリシーを作成して割り当て!   カスタムポリシーの例例  (TVMのサンプルに同梱){ "Statement": [{ "Effect": "Allow", "Action": "sts:GetFederationToken", "Resource": "*" },{ "Effect": "Allow", "Action": "iam:GetUser", "Resource": "*" },{ "Effect": "Allow", "Action": "sdb:*", "Resource": "*" },{ "Effect":"Allow", "Action":"dynamodb:*", "Resource":"*" },{ "Effect": "Allow", "Action": "sqs:*", "Resource": "*" },{ "Effect": "Allow", "Action": "s3:*", "Resource": "*" },{"Effect": "Allow", "Action": "sns:*", "Resource": "*" }]}アプリケーションで必要最小限な権限になるよう更新© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
TVMがデプロイされたことを確認!   TVMをデプロイしたHTTPコンテナにアクセス設定に関する警告が消えて、Security TokenServiceにアクセス出来るようになったことを確認本番ではSSL必須:平文ではデバイス/ユーザ登録で秘密鍵/パスワードが流出するリスク© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
[再掲]  認証トークンを⽤用いたサービス利利⽤用の流流れToken Vending Machine (TVM)を導入•  ユーザ/端末の認証とトークンの発行を実施•  アプリケーションごとの認証とAWSの認証機構を結びつけるサービス1.  Security Token Serviceか1ら認証トークンを取得STSから2.  クライアントに認証トークンを提供3.  クライアントは認証トークンを用いてAWSにアクセス3TVMのサンプルを利用12© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
TVMを⽤用いたサンプルを試すAnonymousTVMの動作確認!   samples/S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVM•  設定例例:•  TVM  URL:  http://anon-‐‑‒example.elasticbeanstalk.comAndroid: AwsCredentials.propertiesを編集tokenVendingMachineURL=anon-example.elasticbeanstalk.comiOS: Constants.hを編集#define TOKEN_VENDING_MACHINE_URL @“anon-example.elasticbeanstalk.com”/registerdevice?uid=<UID>&key=<KEY>/gettoken?uid=<UID>&timestamp=<timestamp>&signature=<Sig http://anonexample.elasticbeanstalk.comnature><Encrypted token credentials>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
TVMを⽤用いたサンプルを試すIdentityTVMの動作確認!   samples/S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVMIdentity•  設定例例:•  TVM  URL:  http://id-‐‑‒example.elasticbeanstalk.com•  アプリ名:  exampleApp  (TVMの環境変数”PARAM1”に設定した値)Android: AwsCredentials.propertiesを編集tokenVendingMachineURL=id-example.elasticbeanstalk.comappName=exampleAppiOS: Constants.hを編集#define TOKEN_VENDING_MACHINE_URL @“id-example.elasticbeanstalk.com”#define APP_NAME @“exampleApp"login()registeruser()© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
TVM  Clientのインテグレーション!   Android  /  iOSともにTVM  Clientの実装がサンプルに•  各サンプル内のAmazonClientManagerの実装はTVM  Clientを利利⽤用•  S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVM    à  Anonymous  TVM•  S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVMIdentity    à  IdentityTVM!   おすすめのステップは…1.  ベースとするTVMの実装を決定  (Anonymous  or  Identity)2.  対応するサンプルコード内の実装をコピー• • AmazonClientManagerTVMClient3.  必要に応じてTVM,  TVM  Client,  認証メカニズムをカスタマイズ• Identity  TVMをカスタマイズすればSNSとのID連携も© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

Recommended

PPTX
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
PPTX
20220409 AWS BLEA 開発にあたって検討したこと
PDF
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
PDF
20200218 AWS Black Belt Online Seminar Next Generation Redshift
PDF
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
PDF
AWS Black Belt Online Seminar 2017 AWS体験ハンズオン~Amazon S3 バックアップ~
PDF
AWSサーバレスサービスによるセキュリティログ分析基盤
PDF
オープンソースのAPIゲートウェイ Kong ご紹介
PDF
20200630 AWS Black Belt Online Seminar Amazon Cognito
PDF
20201028 AWS Black Belt Online Seminar Amazon CloudFront deep dive
PDF
[AWSマイスターシリーズ] AWS SDK for PHP / Ruby / boto(Python) / JavaScript in Node.js
PDF
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
PDF
AWSではじめるMLOps
PDF
AWS Black Belt Online Seminar 2017 AWS Cognito
PDF
Amazon Redshift パフォーマンスチューニングテクニックと最新アップデート
PPTX
20211109 bleaの使い方(基本編)
PDF
20190122 AWS Black Belt Online Seminar Amazon Redshift Update
PDF
AWS Black Belt Online Seminar AWS Key Management Service (KMS)
PDF
Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인
PDF
AWS Black Belt Techシリーズ Amazon Kinesis
PPTX
ビッグデータ処理データベースの全体像と使い分け
2018年version
PDF
aws blackbelt amazon elasticsearch service
PDF
Amazon S3を中心とするデータ分析のベストプラクティス
PDF
[JAWS DAYS 2019] Amazon DocumentDB(with MongoDB Compatibility)入門
PDF
webエンジニアのためのはじめてのredis
PPTX
データ収集の基本と「JapanTaxi」アプリにおける実践例
PDF
サイエンス領域におけるMLOpsの取り組み #yjtc
PDF
Apache Atlasの現状とデータガバナンス事例 #hadoopreading
PDF
[AWSマイスターシリーズ] AWS SDK for Java / .NET
PDF
WS Black Belt Online Seminar 2016 RDBのAWSへの移行

More Related Content

PPTX
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
PPTX
20220409 AWS BLEA 開発にあたって検討したこと
PDF
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
PDF
20200218 AWS Black Belt Online Seminar Next Generation Redshift
PDF
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
PDF
AWS Black Belt Online Seminar 2017 AWS体験ハンズオン~Amazon S3 バックアップ~
PDF
AWSサーバレスサービスによるセキュリティログ分析基盤
PDF
オープンソースのAPIゲートウェイ Kong ご紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
20220409 AWS BLEA 開発にあたって検討したこと
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
20200218 AWS Black Belt Online Seminar Next Generation Redshift
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
AWS Black Belt Online Seminar 2017 AWS体験ハンズオン~Amazon S3 バックアップ~
AWSサーバレスサービスによるセキュリティログ分析基盤
オープンソースのAPIゲートウェイ Kong ご紹介

What's hot

PDF
20200630 AWS Black Belt Online Seminar Amazon Cognito
PDF
20201028 AWS Black Belt Online Seminar Amazon CloudFront deep dive
PDF
[AWSマイスターシリーズ] AWS SDK for PHP / Ruby / boto(Python) / JavaScript in Node.js
PDF
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
PDF
AWSではじめるMLOps
PDF
AWS Black Belt Online Seminar 2017 AWS Cognito
PDF
Amazon Redshift パフォーマンスチューニングテクニックと最新アップデート
PPTX
20211109 bleaの使い方(基本編)
PDF
20190122 AWS Black Belt Online Seminar Amazon Redshift Update
PDF
AWS Black Belt Online Seminar AWS Key Management Service (KMS)
PDF
Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인
PDF
AWS Black Belt Techシリーズ Amazon Kinesis
PPTX
ビッグデータ処理データベースの全体像と使い分け
2018年version
PDF
aws blackbelt amazon elasticsearch service
PDF
Amazon S3を中心とするデータ分析のベストプラクティス
PDF
[JAWS DAYS 2019] Amazon DocumentDB(with MongoDB Compatibility)入門
PDF
webエンジニアのためのはじめてのredis
PPTX
データ収集の基本と「JapanTaxi」アプリにおける実践例
PDF
サイエンス領域におけるMLOpsの取り組み #yjtc
PDF
Apache Atlasの現状とデータガバナンス事例 #hadoopreading
20200630 AWS Black Belt Online Seminar Amazon Cognito
20201028 AWS Black Belt Online Seminar Amazon CloudFront deep dive
[AWSマイスターシリーズ] AWS SDK for PHP / Ruby / boto(Python) / JavaScript in Node.js
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
AWSではじめるMLOps
AWS Black Belt Online Seminar 2017 AWS Cognito
Amazon Redshift パフォーマンスチューニングテクニックと最新アップデート
20211109 bleaの使い方(基本編)
20190122 AWS Black Belt Online Seminar Amazon Redshift Update
AWS Black Belt Online Seminar AWS Key Management Service (KMS)
Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인
AWS Black Belt Techシリーズ Amazon Kinesis
ビッグデータ処理データベースの全体像と使い分け
2018年version
aws blackbelt amazon elasticsearch service
Amazon S3を中心とするデータ分析のベストプラクティス
[JAWS DAYS 2019] Amazon DocumentDB(with MongoDB Compatibility)入門
webエンジニアのためのはじめてのredis
データ収集の基本と「JapanTaxi」アプリにおける実践例
サイエンス領域におけるMLOpsの取り組み #yjtc
Apache Atlasの現状とデータガバナンス事例 #hadoopreading

Viewers also liked

PDF
[AWSマイスターシリーズ] AWS SDK for Java / .NET
PDF
WS Black Belt Online Seminar 2016 RDBのAWSへの移行
PDF
[AWSマイスターシリーズ] AWS Billingについて
PDF
AWS Black Belt Techシリーズ Amazon Cognito / Amazon Mobile Analytics
PDF
SAP on AWS 実際の導入例と導入効果
PDF
AWS Black Belt Tech シリーズ 2015 AWS CLI & AWS Tools for Windows Powershell
PDF
AWS初心者向けWebinar .NET開発者のためのAWS超入門
PDF
初心者向けWebinar AWSでDRを構築しよう
PDF
AWS Black Belt Techシリーズ Amazon AppStream
PDF
Provisioning & Deploy on AWS
PDF
AWS 初心者向けWebinar AWS上にWebサーバシステムを作ってみましょう~まずは仮想サーバーから[演習つき]
PDF
SDK不要で高パフォーマンス!AppLovinのネイティブ広告_20160427
PPTX
React を導入した フロントエンド開発
PDF
Atomic Design powered by React @ AbemaTV
PDF
AWS Mobile SDK利用時のテスト手法
PDF
20120625 aws meister-reloaded-sg-vmie-public
PDF
AWS Black Belt Techシリーズ AWS re:Invent 2014 最新情報のアップデート
PDF
Blackbelt Online Serminar Parse.comからAWSへのモバイルアプリの移行
PDF
AWS Black Belt Online Seminar 10 Years of AWS
PDF
Atomic designで助かった人たち
[AWSマイスターシリーズ] AWS SDK for Java / .NET
WS Black Belt Online Seminar 2016 RDBのAWSへの移行
[AWSマイスターシリーズ] AWS Billingについて
AWS Black Belt Techシリーズ Amazon Cognito / Amazon Mobile Analytics
SAP on AWS 実際の導入例と導入効果
AWS Black Belt Tech シリーズ 2015 AWS CLI & AWS Tools for Windows Powershell
AWS初心者向けWebinar .NET開発者のためのAWS超入門
初心者向けWebinar AWSでDRを構築しよう
AWS Black Belt Techシリーズ Amazon AppStream
Provisioning & Deploy on AWS
AWS 初心者向けWebinar AWS上にWebサーバシステムを作ってみましょう~まずは仮想サーバーから[演習つき]
SDK不要で高パフォーマンス!AppLovinのネイティブ広告_20160427
React を導入した フロントエンド開発
Atomic Design powered by React @ AbemaTV
AWS Mobile SDK利用時のテスト手法
20120625 aws meister-reloaded-sg-vmie-public
AWS Black Belt Techシリーズ AWS re:Invent 2014 最新情報のアップデート
Blackbelt Online Serminar Parse.comからAWSへのモバイルアプリの移行
AWS Black Belt Online Seminar 10 Years of AWS
Atomic designで助かった人たち

Similar to [AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-

PDF
AWS SDK for Android and iOS
PDF
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
PDF
AWSマイスターシリーズReloaded -AWS SDK for .NET-
PDF
Amazon VPCトレーニング-VPCの説明
PDF
[AWS初心者向けWebinar] AWSを活用したモバイルアプリの開発と運用
PDF
AWS All Stars ~Lightning Talks x 13~
PDF
PHP で始める AWS モバイルサービス - PHPカンファレンス_20150530
PDF
AWS SDK for Haskell開発
PDF
AWS Black Belt Techシリーズ AWS SDK
PDF
AWS Introduction for Startups
PPT
アマゾンクラウドの真価
PDF
Serverless backendformobilegame and_aws-appsync_gamingtechnight-2
PDF
[AWS Developers Meetup 2017] Developerのための ライブAWSウォークスルー 〜 AWS SDKの使い方 〜
PDF
AWS Black Belt Online Seminar AWSサービスを利用したアプリケーション開発を始めよう
PDF
20120528 aws meister-reloaded-awssd-kforjava-public
PDF
AWSにおける モバイル向けサービス及び事例紹介(20151211)
PDF
Amazon Web Services(AWS)とcloudpack について
PDF
AWS Black Belt Online Seminar 2017 AWS re:Invent 2017速報
PDF
Cloud Programing for beginner
PDF
モバイル開発を支えるAWS Mobile Services
AWS SDK for Android and iOS
AWS Black Belt Techシリーズ Amazon Elastic Compute Cloud (Amazon EC2)
AWSマイスターシリーズReloaded -AWS SDK for .NET-
Amazon VPCトレーニング-VPCの説明
[AWS初心者向けWebinar] AWSを活用したモバイルアプリの開発と運用
AWS All Stars ~Lightning Talks x 13~
PHP で始める AWS モバイルサービス - PHPカンファレンス_20150530
AWS SDK for Haskell開発
AWS Black Belt Techシリーズ AWS SDK
AWS Introduction for Startups
アマゾンクラウドの真価
Serverless backendformobilegame and_aws-appsync_gamingtechnight-2
[AWS Developers Meetup 2017] Developerのための ライブAWSウォークスルー 〜 AWS SDKの使い方 〜
AWS Black Belt Online Seminar AWSサービスを利用したアプリケーション開発を始めよう
20120528 aws meister-reloaded-awssd-kforjava-public
AWSにおける モバイル向けサービス及び事例紹介(20151211)
Amazon Web Services(AWS)とcloudpack について
AWS Black Belt Online Seminar 2017 AWS re:Invent 2017速報
Cloud Programing for beginner
モバイル開発を支えるAWS Mobile Services

More from Amazon Web Services Japan

PDF
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
PDF
マルチテナント化で知っておきたいデータベースのこと
PDF
Infrastructure as Code (IaC) 談義 2022
PDF
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
PDF
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
PDF
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
PDF
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
PDF
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
PDF
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
PDF
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
PDF
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
PDF
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
PDF
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
PDF
Amazon QuickSight の組み込み方法をちょっぴりDD
PDF
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
PDF
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
PDF
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
PDF
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
PDF
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
PDF
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
マルチテナント化で知っておきたいデータベースのこと
Infrastructure as Code (IaC) 談義 2022
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
202112 AWS Black Belt Online Seminar 店内の「今」をお届けする小売業向けリアルタイム配信基盤のレシピ
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
Amazon QuickSight の組み込み方法をちょっぴりDD
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介

[AWSマイスターシリーズ] AWS Client Side SDK -Android,iOS & JavaScript-

  • 1.
    re:GenerateAWSマイスターシリーズ  AWS  Client-‐‑‒side SDK-‐‑‒  Android,  iOS  and  Javascript  -‐‑‒2014.2.5ソリューションアーキテクト安川  健太   今井  雄太© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 2.
    Agenda!   AWS SDK  オーバービュー!   クライアント側SDKの活⽤用法!   クライアント側SDKにおけるAWS  Credentialsの取り扱い!   各クライアント側SDKの紹介•  AWS  SDK  for  Android•  AWS  SDK  for  iOS•  AWS  SDK  for  JavaScript  in  the  Browser!   まとめ© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 3.
    AWS  SDK  オーバービュー©2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 4.
    AWSのサービス操作と⾔言えばAWS  Management  ConsoleAWSコマンドラインツール©2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 5.
    これらの裏裏側では・・・!   各サービスの各操作にAPIが定義されている!   AWSでは・・・•  ⼈人間がGUIまたはCUI越しに叩く•  プログラミングしてそれを⾃自動化・簡易易化・カスタマイズ•  ⼈人間が⼿手でやらなくてはいけない事をプログラミングして⾃自動化できる、これがSDKで簡単に実現可能à  AWSの実は最も優れた⼀一⾯面© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 6.
    AWS  SDKとは!  AWSのサービスをプログラムで操作できるSDK•  さまざまな⾔言語で• • • • • • • • • • AWS  SDK  for  JavaAWS  SDK  for  .NetAWS  SDK  for  RubyAWS  SDK  for  PHPAWS  SDK  for  Python  (boto)AWS  SDK  for  node.jsAWS  SDK  for  AndroidAWS  SDK  for  iOSAWS  SDK  for  Javascript  in  Browser有志の⽅方による実装(ActionScript)も•  通信は原則HTTPS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 7.
    SDK⼀一般の動作イメージ起動、停⽌止RESTAWS  SDKSOAPPut,GetDB起動バックアップ認証情報情報取得© 2012Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 8.
  • 9.
    クライアント側SDKの活⽤用法© 2012 Amazon.com,Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 10.
    AWSのマネージドサービスを活⽤用した2-‐‑‒tierのアーキテクチャが組める!   モバイル端末やブラウザからAWSの各種サービスを呼ぶ• AWSのマネージドサービスを組み合わせてバックエンドに•  しかもプラットフォーム横断で連携!© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 11.
  • 12.
    例例2:  モバイルアプリ間でメッセージング!  AWSサービスのみで作るチャットアプリ•  サーバ側のコーディングなしで掲⽰示板/チャットサービスを提供DynamoDB・メッセージの保存・チャットグループとメッセージの紐紐付Simple  Notification  Service  (SNS)・新規メッセージの通知Simple  Queue  Service  (SQS)・SNSの通知受け⼝口Simple  Storage  Service  (S3)・画像等のデータの保存先・配信元© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 13.
    例例2:  モバイルアプリ間でメッセージング! DynamoDB, S3を使ってデータ共有2.  DBクエリ  /  ファイルリクエストDynamoDB1.  DB書き込み  /  ファイルアップロード3.  DB応答  /  ファイルダウンロードS3© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 14.
    例例2:  モバイルアプリ間でメッセージング!  SNSとSQSを使ってPub/SubSNS:  Simple  Notification  ServiceSQS:  Simple  Queue  Service+SNS  topicSQS  queue2.  Notify1.  Publish© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 15.
    例例2:  モバイルアプリ間でメッセージングチャットグループへのSubscribe!  過去メッセージはDynamoDBから取得!   SQSでキューを作成し、SNSにSubscribe1.  SQSのキューを作成チャットグループのSNSトピック2.  SNSトピックにSubscribe4.  SNSトピックにPublish5.  SQSを通じて通知クライアントA0.  メッセージ⼀一覧取得クライアントB3.  新メッセージ書き込み© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 16.
    例例2:  モバイルアプリ間でメッセージングチャットグループへのファイルアップロード!  S3にファイルをアップロード!   SNSで通知チャットグループのSNSトピック3.  SNSトピックにPublish4.  SQSを通じて通知クライアントA5.  ファイルダウンロード2.  メッセージ書き込みクライアントB1.  ファイルアップロード© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 17.
    その他の例例⾮非同期バッチ処理理!   ⾮非同期バッチ処理理要求を直接登録• 通常のWebアプリ等Job  queueClientWorkersWeb  Frontend•  Android/iOS/Javascript  SDKを使った場合Job  queueWorkers© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 18.
    その他の例例ログやイベント情報の集計処理理!   ログやイベント情報を直接登録• 通常のWebアプリ等ClientWeb  Frontendログ・イベント集計•  Android/iOS/Javascript  SDKを使った場合ログ・イベント集計© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 19.
    Amazon  SNSへのデバイストークンの登録も直接可能Apple  DevicesGoogle Devicesント・3.  エンドポイユーザ情報登録2.  エンドポイントAmazon  Kindle  Fire  Devicesエンドポイント取得Push通知Amazon  SNSMobile  Push© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 20.
    クライアント側SDK活⽤用のメリット!   アプリの開発に多くのメリット:• • • • バックエンド側の開発コストを最⼩小化バックエンド側の運⽤用コストを最⼩小化スケーラビリティの⼼心配なし⾦金金額⾯面でもローコスト(当社⽐比*)!  必要に応じてEC2も導⼊入できる安⼼心感•  後からバックエンド側にロジックを⼊入れてシステムの最適化*  EC2で同規模のサーバを⽴立立てる場合に⽐比べ© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 21.
    AWS  CREDENTIALSの取扱い© 2012Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 22.
    誰のAWSアカウントを使う?!   AWSのコンソールアプリを作る場合• エンドユーザはAWSユーザàAWSのアクセスキーとシークレットキーを⼊入⼒力力してもらえばOK!   AWSの各種サービスを使ったアプリを作る場合•  AWSの各種サービスはあくまでバックエンド•  エンドユーザは必ずしもAWSユーザではないàアプリは開発者のアカウントで認証・認可を受ける必要© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 23.
    開発者アカウントを使うとして…!   アプリに開発者アカウントのアクセスキー等を埋め込んだら• アクセスキーが広範にばら撒かれることに•  アクセスキーの不不正利利⽤用を⽌止めるためにキーを無効化したらà全ユーザへのサービスが停⽌止!!!   アクセスキーの定期的な更更新で対処するにしても•  更更新のたびにバージョンアップは⾮非現実的•  更更新前のアプリからはサービス利利⽤用不不可に© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 24.
    セキュアなAWSアクセスを提供するには!   アプリに認証情報を埋め込むべきではない!  エンドユーザ/端末ごとに異異なるCredentialsを提供すべき•  ユーザごとに必要最⼩小限の権限を与えるのは重要•  不不正利利⽤用発覚時に不不正ユーザのみ権限を停⽌止!   Credentialsは期限が来たら無効化されるべき•  不不正ユーザの影響も期限付きにこれを実現する仕組みあります!© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 25.
    Security  Token  Service!  AWSに対する、⼀一時的な認証情報を作成する仕組み•  期限付きの認証情報(認証チケット)を発⾏行行•  Identity  and  Access  Management  (IAM)サービスの機能!   ユーザーに対して、以下の3つのキーを発⾏行行§  アクセスID§  シークレットキー§  セッショントークン!   作成した認証情報の有効期限設定が可能§  デフォルト12時間  最⼩小1時間  最⼤大36時間§  ただし延⻑⾧長・短縮は出来ない但し、STS⾃自体は認証の機能を持たないため、認証の仕組みは別途必要© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 26.
    認証機構とSTSとをインテグレーションする際の選択肢{Facebook,  Google,  Amazon} のIDで認証YesWeb  Identity  Federationを利利⽤用可!YesIdentity  TVMが選択肢にNo独⾃自の認証付きToken  Vending  Machine  (TVM)実装が必要ユーザごとに異異なる権限を与える必要ありNoAnonymous  TVMが選択肢に© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 27.
    Web Identity Federation!  Web Identity Providerの認証結果を受けてAWSの各種サービスへのアクセスを認可する仕組み!   IAM RoleのAssume機能を利用して実現•  Web Identity Providerによって認証されたユーザは特定のIAM Roleを持つものと見なす(Assume)する!   対応Identity Providerは•  Facebook•  Google•  Amazon© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 28.
    Web  Identity  Federationの動作フローSTS⾃自体が認証済みユーザにアクセストークンを発⾏行行するToken Vending  Machine  (TVM)の役割を担っている詳細はマイスターシリーズIAM回を参照:  http://www.slideshare.net/AmazonWebServicesJapan/20130716-‐‑‒aws-‐‑‒meisterregenerateiampublic© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 29.
    Web  Identity  Federation利利⽤用時のコード例例!  AndroidWebIdentityFederationSessionCredentialsProvider  wif  =                  new  WebIdentityFederationSessionCredentialsProvider(fbSession.getAccessToken(),                                                                                                                          "graph.facebook.com",                                                                                                                          ROLE_̲ARN);String  subjectFromWIF  =  wif.getSubjectFromWIF();  s3  =  new  AmazonS3Client(wif);!iOSAmazonWIFCredentialsProvider  *wif  =  [[AmazonWIFCredentialsProvider  alloc]initWithRole:ROLE_̲ARNandWebIdentityToken:self.session.accessTokenData.accessToken                                                                fromProvider:@"graph.facebook.com"];NSString  *subjectFromWIF  =  wif.subjectFromWIF;s3  =  [[[AmazonS3Client  alloc]  autorelease]  initWithCredentialsProvider:wif];© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 30.
    独⾃自の認証機構を⽤用いる場合Token  Vending  Machine (TVM)を導⼊入•  ユーザ/端末の認証とトークンの発⾏行行を実施•  アプリケーションごとの認証とSTSを結びつけるための仕組み1.  Security  Token  Serviceから認証トークンを取得1  STSから2.  クライアントに認証トークンを提供3.  クライアントは認証トークンを⽤用いてAWSにアクセス3アプリの認証機構に合わせて任意の実装12© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 31.
    TVMの実装⽅方針を⼤大別すると! AnonymousTVM•  ユーザ認証を必要とせず、⼀一時認証トークンの機能のみ利利⽤用したいユースケース向け• 例例:誰でも参加出来る掲⽰示板システム、ログの記録! IdentityTVM•  ユーザ認証を実施し、認証されたユーザにのみ認証トークンを発⾏行行するユースケース向け•  例例:ユーザ認証を伴うソーシャルアプリ、ゲーム等どちらもサンプルの実装がサーバ側・クライアント側とも公開されている© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 32.
    Anonymous  TVM!  デバイス固有のIDと対応する秘密鍵をTVMに登録!   秘密鍵を使って認証トークンを暗号化して提供デバイス固有のIDと秘密鍵を登録秘密鍵を使って© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 33.
  • 34.
    Web  Identityを⽤用いたFine  Grained Access  Control!   例例1:  S3バケット内にユーザごとのプライベートな領領域を作成{  "Version":"2012-‐‑‒10-‐‑‒17",      "Statement":[      {  "Effect":"Allow",        "Action":["s3:GetObject",  "s3:PutObject",  "s3:DeleteObject"],          "Resource":[                "arn:aws:s3:::myBucket/myApp/${graph.facebook.com:id}",                  "arn:aws:s3:::myBucket/myApp/${graph.facebook.com:id}/*“          ]    }  ]Facebookにログインした}ユーザーのIDが⼊入る© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 35.
    Web  Identityを⽤用いたFine  Grained Access  Control!   例例2:  DynamoDBのテーブル内にユーザごとにプライベートな⾏行行/列列を定義する  "Condition":  {                "ForAllValues:StringEquals":  {                    "dynamodb:LeadingKeys":  [                        "${www.amazon.com:user_̲id}"                    ],                    "dynamodb:Attributes":  [                        "UserId”,"GameTitle”,  "Wins”,  "Losses”                    ]                },                "StringEqualsIfExists":  {                    "dynamodb:Select":  "SPECIFIC_̲ATTRIBUTES"                }            }© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 36.
    各クライアント側SDKの紹介© 2012 Amazon.com,Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 37.
    AWS  SDK  FOR ANDROID© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 38.
    AWS  SDK  for Androidとは!   Amazon提供のAWS開発⽤用のAndroid向けSDK!   公式ページ:http://aws.amazon.com/jp/sdkforandroid/!   環境:Android  2.3  (API  level  10)以上!   利利⽤用⽅方法•  公式ページからダウンロード•  GitレポジトリからMavenをお使いの場合:公式MavenレポジトリLocalレポジトリにインストールしての利利⽤用は可(但し、正式サポートの範囲外)© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 39.
    操作可能サービスEC2S3DynamoDBSimpleDBSNSSQSSESELBCloudWatchAutoscaling※サポートするサービスの範囲はiOS  SDKと同様© 2012Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 40.
    SDKに含まれるもの!   AWS Android  ライブラリ•  各種サービス向けAPIを提供するJavaライブラリ•  Androidアプリのプロジェクトから参照•  最終的にはAPKに内包!   ソースコード!   ドキュメント(コードサンプルはGitレポジトリに移動)https://github.com/awslabs/aws-‐‑‒sdk-‐‑‒android-‐‑‒samples• • • • • • 各種サービスの操作SNSとSQSを使ったメッセージボードS3アップローダSimpleDB  ハイスコアSESフィードバックフォームDynamoDBを使ったユーザプリファレンス© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 41.
    初期設定!   プロジェクトの依存関係にAndroid SDKを追加•  EclipseとAndroid  SDKを使っている場合の例例:必要なライブラリをプロジェクトのlibs配下にコピー注:他の場所に配置する場合は最終的なAPKにクラスファイルが含まれるようにすること© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 42.
    依存するJarファイルについてTips!   開発時はデバッグシンボル付きのライブラリを使⽤用aws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒debug.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒ddb-‐‑‒mapper-‐‑‒debug.jar!  配布時は必要なサービスのみ同梱全部⼊入りaws-‐‑‒android-‐‑‒sdk-‐‑‒<version>.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒ddb-‐‑‒mapper.jarDynamoDBMapperを使う場合に必要必要なサービスのみaws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒core.jar        +      aws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒ddb.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒s3.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒sns.jaraws-‐‑‒android-‐‑‒sdk-‐‑‒<version>-‐‑‒sqs.jarあるいはproguardを使って必要なパッケージのみ同梱© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 43.
    コード例例!   基本的な流流れ(iOSも同様)• • • • 利利⽤用するサービスのクライアントオブジェクトの作成サービスのリクエストオブジェクトを作成クライアントオブジェクトを通じてリクエストレスポンスを受け取るS3にファイルをアップロードする例例void uploadToS3  (String  bucketName,  String  objectName,  File  file){      AmazonCredentials  credentials  =  new  BasicAmazonCredentials(ACCESS_̲KEY,  SECRET_̲KEY);      AmazonS3Client  s3  =  new  AmazonS3Client(credentials);      PutObjectRequest  req  =  new  PutObjectRequest(bucketName,  objectName,  file));      PutObjectResponse  resp  =  s3.putObject(req);}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 44.
    コード例例:S3へのアップロード  (⾮非同期)S3UploadTask  uploadTask =  new  S3UploadTask();uploadTask.execute(new  PutObjectRequest(bucketName,  objectName,  tempFile));private  class  S3UploadTask  extends  AsyncTask<PutObjectRequest,  Long,  Long>  implements  ProgressListener  {protected  Long  totalSent;バックグラウンド実⾏行行//  AsyncTask#doInBackground()protected  Long  doInBackground  (PutObjectRequest...  reqs)  {totalSent  =  0L;reqs[0].setProgressListener(this);S3.getInstance().putObject(reqs[0]);return  totalSent;}  //  ProgressListener#progressChanged()進⾏行行状 public  void  progressChanged  (ProgressEvent  progressEvent)  { totalSent  +=  progressEvent.getBytesTransfered();publishProgress(totalSent);況の更更}新}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 45.
    コード例例:DynamoDBへのQueryハッシュキーとレンジキーのMaxを指定して特定のテーブルにクエリを送る例QueryResult doQuery (StringhashKey, String max) {ハッシュキーを AttributeValue hashKey = new AttributeValue().withS(hashKey);指定Condition lessThanMax = new Condition().withComparisonOperator(ComparisonOperator.LT)条件を.withAttributeValueList(new AttributeValue().withN(max));指定QueryResult result = dynamoClient.query(new QueryRequest().withTableName(TABLE_NAME)クエリを.withLimit(NUMBER_OF_ITEMS_TO_GET_AT_ONCE)実行.withHashKeyValue(hashKey).withRangeKeyCondition(lessThanMax));return result;}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 46.
    コード例例:DynamoDBMapperでDynamoDBにオブジェクトを永続化POJOを定義@DynamoDBTable(tableName = “meisters_items”)publicclass MeistersItem {private String id;private long value;@DynamoDBHashKey(attributeName = “id”)public String getId() {return id;}@DynamoDBHashKey(attributeName = “id”)public void setId(String id) {this.id = id;}@DynamoDBAttribute(attributeName = “value”)public long getValue() {return time;}}DynamoDBMapperを初期化AmazonDynamoDBClient dynamoClient =new AmazonDynamoDBClient(getCredentials());AmazonDynamoDBMapper dbMapper =new DynamoDBMapper(getDynamoClient());POJOの保存MeisterItem item = new MeisterItem();item.setId(“Expensive item”);item.setValue(10000);dbMapper.save(item);POJOの読み込みMeisterItem item = dbMapper.load(MeisterItem.class,“Expensive item”);@DynamoDBAttribute(attributeName = “value”)public void setValue(long time) {this.time = time;}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 47.
    Android  SDK利利⽤用時のTips!  UIスレッドからAWSのAPIを呼ぶのは避ける•  適宜AsyncTaskや別Threadを使⽤用!   各サービスクライアントのインスタンスは再利利⽤用•  サービスクライアントの実装はThread  Safe•  Singletonにすることで重いオブジェクト⽣生成を最⼩小限に•  例例:サンプル内のAmazonClientManagerpublic  class  AmazonClientManager  {  //  下記コードは簡易易版        private  AmazonS3Client  s3Client  =  null;        public  AmazonS3Client  s3()  {                if  (s3Client  ==  null)  s3Client  =  new  AmazonS3Client(  credentials  );                return  s3Client;        }  }!   ユースケース別の解説付きコードサンプルがこちらに:•  http://aws.amazon.com/articles/SDKs/Android© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 48.
    AWS  SDK  FOR IOS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 49.
    AWS  SDK  for iOSとは!   Amazon提供のAWS開発⽤用iOS  SDK!   公式ページ:http://aws.amazon.com/jp/sdkforios/!   動作環境:iOS  4.3以上  !   開発環境:Xcode  v4以上!   利利⽤用⽅方法•  公式ページからダウンロード•  Gitレポジトリから© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 50.
    操作可能サービスEC2S3DynamoDBSimpleDBSNSSQSSESELBCloudWatchAutoscaling※サポートするサービスの範囲はAndroid  SDKと同様© 2012Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 51.
    SDKに含まれるもの!   AWS iOSライブラリ•  各種サービス向けAPIを提供するObjective-‐‑‒Cライブラリ•  iOSアプリプロジェクトのフレームワークの1つとして参照!   ドキュメント!   ソースコード(コードサンプルはGitレポジトリに移動)https://github.com/awslabs/aws-‐‑‒sdk-‐‑‒ios-‐‑‒samples• • • • • • • 各種サービスの操作SNSとSQSを使ったメッセージボードS3アップローダSimpleDB  ハイスコアSESフィードバックフォームDynamoDBを使ったユーザプリファレンスDynamoDB  を  CoreDataフレームワークのバックエンドに© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 52.
    初期設定  〜~Frameworkの追加〜~!  プロジェクトにSDKを追加1.  Xcodeにてプロジェクトを開く2.  Frameworks  GroupをCtrlを押しながらクリック3.  AWSiOSSDK.frameworkを追加• AWSPersistence.frameworkは任意(DynamoDB  +  CoreDataを使ったPersistenceを利利⽤用する場合)4.  ソースコードで必要なヘッダファイルをインクルード•  例例#import  <AWSiOSSDK/S3/AmazonS3Client.h>#import  <AWSiOSSDK/SimpleDB/AmazonSimpleDBClient.h>#import  <AWSiOSSDK/SQS/AmazonSQSClient.h>#import  <AWSiOSSDK/SNS/AmazonSNSClient.h>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 53.
    初期設定  〜~ドキュメントのインストール〜~!  ドキュメントセットをXcodeにインストール• SDKのディレクトリからdocsetファイルをコピー• これを  – • Documentation/com.amazon.aws.ios.docsetここに  – $HOME/Library/Developer/Shared/Documentaion/DocSets$  mkdir  –p  $HOME/Library/Developer/Shared/Documentaion/DocSets$  cp  Documentation/com.amazon.aws.ios.docset  $HOME/Library/Developer/Shared/Documentaion/DocSets• Xcodeを再起動© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 54.
    コード例例!   基本的な流流れ (Androidも同様)• • • • 利利⽤用するサービスのクライアントオブジェクトの作成サービスのリクエストオブジェクトを作成クライアントオブジェクトを通じてリクエストレスポンスを受け取るS3にファイルをアップロードする例例-‐‑‒  void  uploadToS3:  (NSString*)  bucketName  keyName:  (NSString  *)  keyName  fileName:  (NSString  *)  fileName  {      S3PutObjectRequest  *putObjectRequest  =                [[[S3PutObjectRequest  alloc]  initWithKey:keyName  inBucket:bucketName]  autorelease];        putObjectRequest.filename  =  fileName;        [[AmazonClientManager  s3]  putObject:putObjectRequest];}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 55.
    コード例例:S3へのアップロード(⾮非同期)1/2  NSOperationのサブクラスとしてS3 Uploaderを実装#import<Foundation/Foundation.h>#import <AWSiOSSDK/AmazonServiceRequest.h>@interface AsyncImageUploader:NSOperation<AmazonServiceRequestDelegate>{…- (void) start {….// Puts the file as an object in the bucket.S3PutObjectRequest *putObjectRequest =[[[S3PutObjectRequest alloc] initWithKey:keyName inBucket:bucketName] autorelease];putObjectRequest.filename = filename;Delegateとして途中経過や結果を受けputObjectRequest.delegate = self;取れるように登録[[AmazonClientManager s3] putObject:putObjectRequest];}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 56.
    コード例例:S3へのアップロード(⾮非同期)2/2  Delegateパターンで途中経過や結果を受け取り完了時の処理-(void) request:(AmazonServiceRequest*)requestdidCompleteWithResponse:(AmazonServiceResponse *)response{[self performSelectorOnMainThread:@selector(hideProgressView)withObject:nil waitUntilDone:NO];[self finish];}進行状況の更新処理-(void) request:(AmazonServiceRequest *)requestdidSendData:(NSInteger)bytesWrittentotalBytesWritten:(NSInteger) totalBytesWrittentotalBytesExpectedToWrite:(NSInteger) totalBytesExpectedToWrite{[self performSelectorOnMainThread:@selector(updateProgressView:)withObject:[NSNumber numberWithFloat: (float)totalBytesWritten / totalBytesExpectedToWrite] waitUntilDone:NO];}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 57.
    コード例例:DynamoDBへのQuery-(DynamoDynamoDBQueryResponse *) doQuery:(NSString*) hashKeymax: (NSString *) max {DynamoDBQueryRequest *req = [[DynamoDBQueryRequest alloc] autorelease];req.tableName = TABLE_NAME;ハッシュ req.limit = [[NSNumber alloc] initWithInt: NUMBER_OF_ITEMS_TO_GET_AT_ONCE];キーを req.hashKeyValue = [[DynamoDBAttributeValue alloc] initWithS: hashKey] autorelease];指定DynamoDBCondition *lessThanMax = [[DynamoDBCondition alloc] autorelease];[req.rangeKeyCondition setComparisonOperator: @“LT"];[req.rangeKeyCondition addAttributeValueList:[[[DynamoDBAttributeValue alloc] initWithN: max] autorelease]];req.rangeKeyCondition = lessThanMax;条件を指定クエリをDynamoDBQueryResponse *resp = [[AmazonClientManager dynamodb] query: req];実行return resp;}© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 58.
    iOS  SDK利利⽤用時のTips!  UIスレッドからAWSのAPIを呼ぶのは避ける•  適宜NSOperationやGCD等を使⽤用!   各サービスクライアントのインスタンスは再利利⽤用•  サービスクライアントの実装はThread  Safe•  例例:サンプル内のAmazonClientManager#import  "AmazonClientManager.h"static  AmazonS3Client              *s3    =  nil;@implementation  AmazonClientManager+(AmazonS3Client  *)s3{        if(s3  ==  nil)  s3    =  [[AmazonS3Client  alloc]  initWithCredentials:credentials];        return  s3;}!   ユースケース別の解説付きコードサンプルがこちらに:•  http://aws.amazon.com/articles/SDKs/iOS© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 59.
    AWS  SDK  FOR JAVASCRIPT  IN  WEB  BROWSER© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 60.
    AWS  SDK  for JavaScript  in  the  Browserとは!   Amazon提供のブラウザで動作するJavaScript環境のためのAWS  SDK•  node.js環境のためのSDKは別に存在する!   公式ページ:http://aws.amazon.com/jp/sdkforbrowser/!   環境:!   利利⽤用⽅方法•  公式ページからダウンロード•  Gitレポジトリから© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 61.
    操作可能サービスDynamoDBS3SQSSNS© 2012 Amazon.com,Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 62.
    初期設定(1/2)!   HTML内にJavaScriptを読み込む• SDKをインターネット上の任意の場所に配置し、Scriptタグで読み込む•  <script  type="text/javascript"  src=”PATH/TO/YOUR/SDK"></script>•  AWSで⽤用意するCDN上に配置されたSDKを使う•  <script  type="text/javascript"  src="https://sdk.amazonaws.com/js/aws-‐‑‒sdk-‐‑‒2.0.0-‐‑‒rc1.min.js"></script>!   読み込まれると、“AWS”というグローバル変数が利利⽤用可能になる© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 63.
    初期設定(2/2)! WebIdentityFederationでAWS  Credentialを取得// FacebookのAccessTokenを使ってAWSのCredentialを取得するwindow.fbAsyncInit  =  function()  {                FB.init({  appId:  appId  });                FB.login(function(response)  {                    AWS.config.credentials  =  new  AWS.WebIdentityCredentials({                        ProviderId:  'graph.facebook.com',                        RoleArn:  roleArn,        //  IAM  RoleのARN                        WebIdentityToken:  response.authResponse.accessToken                    });                    fbUserId  =  response.authResponse.userID;                    button.style.display  =  'block';                });};//  FacebookのSDK読み込み(function(d,  s,  id){        var  js,  fjs  =  d.getElementsByTagName(s)[0];        if  (d.getElementById(id))  {return;}        js  =  d.createElement(s);  js.id  =  id;        js.src  =  "//connect.facebook.net/en_̲US/all.js";        fjs.parentNode.insertBefore(js,  fjs);}(document,  'script',  'facebook-‐‑‒jssdk')); be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not
  • 64.
    コード例例:S3へのアップロード<input  type="file"  id="file-‐‑‒chooser" /><button  id="upload-‐‑‒button"  style="display:  none”>Upload  to  S3</button><script  type="text/javascript”>//AWS.config.credentialにCredentialが取得済みの状態でvar  bucket  =  new  AWS.S3({params:  {Bucket:  “YOUR_̲BUCKET_̲NAME”}});button.addEventListener('click',  function()  {                var  file  =  fileChooser.files[0];                if  (file)  {                    results.innerHTML  =  '';                    var  objKey  =  “KEY_̲NAME”;                    var  params  =  {Key:  objKey,  Body:  file,  ACL:  'public-‐‑‒read'};                    bucket.putObject(params,  function  (err,  data)  {                        if  (err)  {                            console.log(err);                        }  else  {                            console.log(data);                        }                    });              }},  false);</script>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 65.
    コード例例:DynamoDBへのputItem<button  id="upload-‐‑‒button"  style="display: none">Put  to  DynamoDB</button><script  type="text/javascript”>//AWS.config.credentialにCredentialが取得済みの状態でvar  dynamodb  =  new  AWS.DynamoDB({region:'ap-‐‑‒northeast-‐‑‒1'});button.addEventListener('click',  function()  {          var  params  =  {                      TableName:  'test',                                Item:  {                                        'title':  {S:  appId  +  'aaa'},                                        'message':  {S:  'Good  Morning'}                    }          };        dynamodb.putItem(params,  function(err,  data)  {                    if  (err)  {                                        console.log(err);                    }else{                                        console.log(data);                    }          });},  false);</script>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 66.
    まとめ© 2012 Amazon.com,Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 67.
    まとめ!   クライアント側SDKを⽤用いて2-‐‑‒tierアーキテクチャを実現• • • • バックエンド側の開発コストを最⼩小化バックエンド側の運⽤用コストを最⼩小化スケーラビリティの⼼心配なし⾦金金額⾯面でもコスト削減に!  Web  Identity  Federationや認証トークン機構を使うことでクライアントアプリからのAWSへのアクセスも安⼼心!   AWSはコーディングする⽅方の⼒力力を最⼤大限に引き出すインフラ•  その恩恵はサーバ側だけでなくクライアントアプリにも!•  HAPPY  CODING!!© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 68.
    ご参加ありがとうございました© 2012 Amazon.com,Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 69.
    TVM導⼊入の流流れ!   認証トークンに割り当てるユーザ権限を設定• Identity  and  Access  Management  (IAM)でユーザを作成•  アプリケーションに合わせたポリシーを割り当て!   TVMを実装し、デプロイ•  サンプルはWARファイルをデプロイするだけで実⾏行行可•  AnonymousTVM•  IdentityTVMàElasticBeanstalkを使うと簡単!!   TVMの各種設定•  Security  Token  Serviceにアクセスするためのアクセスキー設定•  SSLの設定(推奨)© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 70.
    認証トークンに割り当てるユーザ権限を設定(1/2)!   IAMでTVM⽤用の新しいユーザを作成(例例:TVMUser)!  認証情報(アクセスキー・シークレットキー)を保存後でTVMアプリケーション側に設定するので大切に保存© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 71.
    認証トークンに割り当てるユーザ権限を設定(2/2)!   カスタムポリシーを作成して割り当て!  カスタムポリシーの例例  (TVMのサンプルに同梱){ "Statement": [{ "Effect": "Allow", "Action": "sts:GetFederationToken", "Resource": "*" },{ "Effect": "Allow", "Action": "iam:GetUser", "Resource": "*" },{ "Effect": "Allow", "Action": "sdb:*", "Resource": "*" },{ "Effect":"Allow", "Action":"dynamodb:*", "Resource":"*" },{ "Effect": "Allow", "Action": "sqs:*", "Resource": "*" },{ "Effect": "Allow", "Action": "s3:*", "Resource": "*" },{"Effect": "Allow", "Action": "sns:*", "Resource": "*" }]}アプリケーションで必要最小限な権限になるよう更新© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 72.
    TVMがデプロイされたことを確認!   TVMをデプロイしたHTTPコンテナにアクセス設定に関する警告が消えて、SecurityTokenServiceにアクセス出来るようになったことを確認本番ではSSL必須:平文ではデバイス/ユーザ登録で秘密鍵/パスワードが流出するリスク© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 73.
    [再掲]  認証トークンを⽤用いたサービス利利⽤用の流流れToken VendingMachine (TVM)を導入•  ユーザ/端末の認証とトークンの発行を実施•  アプリケーションごとの認証とAWSの認証機構を結びつけるサービス1.  Security Token Serviceか1ら認証トークンを取得STSから2.  クライアントに認証トークンを提供3.  クライアントは認証トークンを用いてAWSにアクセス3TVMのサンプルを利用12© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 74.
    TVMを⽤用いたサンプルを試すAnonymousTVMの動作確認!   samples/S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVM• 設定例例:•  TVM  URL:  http://anon-‐‑‒example.elasticbeanstalk.comAndroid: AwsCredentials.propertiesを編集tokenVendingMachineURL=anon-example.elasticbeanstalk.comiOS: Constants.hを編集#define TOKEN_VENDING_MACHINE_URL @“anon-example.elasticbeanstalk.com”/registerdevice?uid=<UID>&key=<KEY>/gettoken?uid=<UID>&timestamp=<timestamp>&signature=<Sig http://anonexample.elasticbeanstalk.comnature><Encrypted token credentials>© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 75.
    TVMを⽤用いたサンプルを試すIdentityTVMの動作確認!   samples/S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVMIdentity• 設定例例:•  TVM  URL:  http://id-‐‑‒example.elasticbeanstalk.com•  アプリ名:  exampleApp  (TVMの環境変数”PARAM1”に設定した値)Android: AwsCredentials.propertiesを編集tokenVendingMachineURL=id-example.elasticbeanstalk.comappName=exampleAppiOS: Constants.hを編集#define TOKEN_VENDING_MACHINE_URL @“id-example.elasticbeanstalk.com”#define APP_NAME @“exampleApp"login()registeruser()© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 76.
    TVM  Clientのインテグレーション!  Android  /  iOSともにTVM  Clientの実装がサンプルに•  各サンプル内のAmazonClientManagerの実装はTVM  Clientを利利⽤用•  S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVM    à  Anonymous  TVM•  S3_̲SimpleDB_̲SNS_̲SQS_̲DemoTVMIdentity    à  IdentityTVM!   おすすめのステップは…1.  ベースとするTVMの実装を決定  (Anonymous  or  Identity)2.  対応するサンプルコード内の実装をコピー• • AmazonClientManagerTVMClient3.  必要に応じてTVM,  TVM  Client,  認証メカニズムをカスタマイズ• Identity  TVMをカスタマイズすればSNSとのID連携も© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

[8]ページ先頭

©2009-2025 Movatter.jp