0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

API Gateway経由でLambdaを呼び出す

Last updated at Posted at 2023-01-02

概要

API Gatewayを自身で構築したことがなかったので、簡単なものを構築してみた。
/test(GET)でLambdaを呼び出せるようにする。

手順

  1. Lambda関数を作成
  2. API GatewayでREST APIを作成
  3. APIをデプロイする
  4. APIにアクセス

Lambda関数を作成

image.png
コードは初期のまま

export const handler = async(event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
};

API GatewayでREST APIを作成

REST APIを作成

create-restapi.png
image.png

リソースを作成

image.png
image.png

メソッドの作成

image.png
image.png
image.png

APIをデプロイ

image.png
image.png

APIにアクセス

curl https://xxxxxxx.execute-api.ap-northeast-1.amazonaws.com/prod/test
>> "Hello from Lambda!"
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?