世間の方々よりも少し遅いけど、AWS Lambda function URLs を試してみよう
AWS マネジメントコンソール Lambda から
作成された URL:https://ej2mqhfzpd45oazcipkwzihvya0iegzm.lambda-url.us-west-2.on.aws/
- 関数の中身を変更してみる
- event をログ出力する
exports.handler = async (event) => {
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify(event, null, 2)
};
return response;
};
-
deploy ボタンを押してURlアクセス
-
ブラウザに表示された内容
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/",
"rawQueryString": "",
"headers": {
"sec-fetch-mode": "navigate",
"sec-fetch-site": "cross-site",
"accept-language": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"x-forwarded-for": "xxx.xx.xx.xx",
"sec-fetch-user": "?1",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\", \"Google Chrome\";v=\"100\"",
"sec-ch-ua-mobile": "?0",
"x-amzn-trace-id": "Root=1-62598bcb-69680d4b1cba0ce16f1421c3",
"sec-ch-ua-platform": "\"Windows\"",
"host": "ej2mqhfzpd45oazcipkwzihvya0iegzm.lambda-url.us-west-2.on.aws",
"upgrade-insecure-requests": "1",
"cache-control": "max-age=0",
"accept-encoding": "gzip, deflate, br",
"sec-fetch-dest": "document",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
},
"requestContext": {
"accountId": "anonymous",
"apiId": "ej2mqhfzpd45oazcipkwzihvya0iegzm",
"domainName": "ej2mqhfzpd45oazcipkwzihvya0iegzm.lambda-url.us-west-2.on.aws",
"domainPrefix": "ej2mqhfzpd45oazcipkwzihvya0iegzm",
"http": {
"method": "GET",
"path": "/",
"protocol": "HTTP/1.1",
"sourceIp": "xx.xx.xx.xx",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
},
"requestId": "90d3ce44-7c41-4b63-bc55-704b4e8b6e11",
"routeKey": "$default",
"stage": "$default",
"time": "15/Apr/2022:15:14:19 +0000",
"timeEpoch": 1650035659266
},
"isBase64Encoded": false
}
-
https://ej2mqhfzpd45oazcipkwzihvya0iegzm.lambda-url.us-west-2.on.aws/foor/bar/
URLのドメイン以降に付加してみる
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/foor/bar",
"rawQueryString": "",
"headers": {
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"accept-language": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"x-forwarded-for": "xx.xx.xx.xx",
"sec-fetch-user": "?1",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\", \"Google Chrome\";v=\"100\"",
"sec-ch-ua-mobile": "?0",
"x-amzn-trace-id": "Root=1-62598c07-71b759e8321e5c3b6658ec32",
"sec-ch-ua-platform": "\"Windows\"",
"host": "ej2mqhfzpd45oazcipkwzihvya0iegzm.lambda-url.us-west-2.on.aws",
"upgrade-insecure-requests": "1",
"accept-encoding": "gzip, deflate, br",
"sec-fetch-dest": "document",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
},
"requestContext": {
"accountId": "anonymous",
"apiId": "ej2mqhfzpd45oazcipkwzihvya0iegzm",
"domainName": "ej2mqhfzpd45oazcipkwzihvya0iegzm.lambda-url.us-west-2.on.aws",
"domainPrefix": "ej2mqhfzpd45oazcipkwzihvya0iegzm",
"http": {
"method": "GET",
"path": "/foor/bar",
"protocol": "HTTP/1.1",
"sourceIp": "xxx.xx.xx.xx",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
},
"requestId": "2eb6db32-e31f-4302-ad56-8c898e66628d",
"routeKey": "$default",
"stage": "$default",
"time": "15/Apr/2022:15:15:19 +0000",
"timeEpoch": 1650035719215
},
"isBase64Encoded": false
}
"rawPath": "/foor/bar",
アクセスされた内容が取得できる、GET相当が取得できる