Try   HackMD

【Python勉強会】AWS情報

0.目次

1.AWSを利用したLine連携の仕組み(参考情報)
2.Lambda関数の編集
3.Lambda関数のログ確認


1.AWSを利用したLine連携の仕組み(参考情報)

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

①個人のスマホからLine公式アカウントにメッセージ送信
②Line公式からWebhookしたAPI GatewayのURLへメッセージを送信
③API Gatewayに関連付けられたLambdaを呼び出し
④Lambdaで作り込んだ処理に沿ってメッセージを応答


2.Lambda関数の編集

2-1.AWSへログイン
    ログイン情報は「データ」シート参照

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

2-2.上部メニューより「lambda」を検索して選択

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

2-3.左メニューから「関数」を選択
    表示された一覧から自分のLambda関数をクリック

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

2-4.「コード」より「lambda_function.py」を編集

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

2-5.編集が完了した「File」メニューから「Save」を選択

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

2-6.「Deploy」をクリックし、「正常に更新されました」のメッセージを確認

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

3.Lambda関数のログ確認

Lambda関数のログは「モニタリング」から確認することが出来る
また「logger.info(文字列)」で任意の内容を出力することも出来る

3-1.logger.infoで出力を設定

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

3-2.Deployしてからスマホからメッセージを送信

3-3.「モニタリング」から「ログ」を選択し、一覧から実行時間のログを選択
    (表示はUTCのため、9時間遅れとなっていることに注意)

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

3-4.想定通りのメッセージが出力されている

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

3-5.構文エラーがある場合は以下のように出力される
    (以下は23行目に構文エラー(Syntax error)があると出力されている)

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →