Slide 17
Slide 17 text
© 2022, Amazon Web Services, Inc. or its affiliates.
https://xxxxx.execute-api.
<>.
amazonaws.com/Prod/
構成・設定
- URL
- 認証
- キャッシュ
- 関数紐付け
※ デフォルトURL
カスタムURL設定可能
public class App implements RequestHandler {
public APIGatewayProxyResponseEvent handleRequest(final
APIGatewayProxyRequestEvent input, final Context context) {
Map headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");
APIGatewayProxyResponseEvent response = new
APIGatewayProxyResponseEvent()
.withHeaders(headers);
try {
final String pageContents =
this.getPageContents("https://checkip.amazonaws.com");
String output = String.format("{ ¥"message¥": ¥"hello world¥", ¥"location¥":
¥"%s¥" }", pageContents);
return response
.withStatusCode(200)
.withBody(output);
} catch (IOException e) {
return response
.withBody("{}")
.withStatusCode(500);
}
}
private String getPageContents(String address) throws IOException{
URL url = new URL(address);
try(BufferedReader br = new BufferedReader(new
InputStreamReader(url.openStream()))) {
return br.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
※ Java の場合
getAllItemsFunction
- テーブル
- データ
- テーブル
- データ
or
RDS
AWS Lambda
DynamoDB