0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

API GatewayからLambdaを呼び出す

Posted at

如何せん資格取得にこだわりすぎて、インプット中心になってしまったので、アウトプットもして行かねばと思い実行。
タイトルにある通りLambdaとAPI Gatewayの連携です。

まずはLambda関数の作成、デフォルトにあるhello worldを使用します。

export const handler = async (event, context) => {
    return 'hellow world';
};

さて次にAPI Gatewayを作成します。
API GatewayにはHTTP APIとREST APIのどちらを選択するか、という話ですが、こちらのページがわかりやすかったです。
今回はLambdaとの連携が目的なので、HTTP APIで良いでしょう。
画面に従って先に作成したLambdaと関連づけ,ルート設定画面でメソッドとリソースパス、ターゲットを指定、ステージはお試しなので$defaultで良いでしょう。
普段ならdev,test,prodみたいなステージで分けるんでしょうけど。
で、作成したAPI Gatewayをデプロイすれば、urlが発行されるので、それをクリックすれば無事Hello worldと出力される=動作するということが確認できます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?