From 964ff7894614fc26ee2b61b591a8fcd36e059c79 Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Tue, 23 Dec 2025 00:54:39 +0900 Subject: [PATCH 1/3] apigw-lambda-rekognition: Use aws_api_gateway_stage --- apigw-lambda-rekognition/main.tf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apigw-lambda-rekognition/main.tf b/apigw-lambda-rekognition/main.tf index 80aa360cd..2ec74de44 100644 --- a/apigw-lambda-rekognition/main.tf +++ b/apigw-lambda-rekognition/main.tf @@ -145,8 +145,14 @@ resource "aws_lambda_permission" "allow_api_gateway" { resource "aws_api_gateway_deployment" "deployment" { depends_on = [aws_api_gateway_integration.integration] rest_api_id = aws_api_gateway_rest_api.api.id - stage_name = "dev" } + +resource "aws_api_gateway_stage" "stage" { + deployment_id = aws_api_gateway_deployment.deployment.id + rest_api_id = aws_api_gateway_rest_api.api.id + stage_name = "dev" +} + output "api_id" { description = "The ID of the API Gateway REST API" value = aws_api_gateway_rest_api.api.id @@ -178,4 +184,4 @@ output "lambda_generate_presigned_url_log_group" { output "lambda_process_s3_event_log_group" { description = "The name of the CloudWatch log group for the process_s3_event Lambda function" value = aws_cloudwatch_log_group.lambda_log_group[1].name -} \ No newline at end of file +} From fe2e81d4ba8cb9b4cd840ec59b52da5e68435a42 Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Wed, 24 Dec 2025 09:38:44 +0900 Subject: [PATCH 2/3] apigw-lambda-rekognition: Add depends_on for "Unable to validate the following destination configurations" error --- apigw-lambda-rekognition/main.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apigw-lambda-rekognition/main.tf b/apigw-lambda-rekognition/main.tf index 2ec74de44..59135cf17 100644 --- a/apigw-lambda-rekognition/main.tf +++ b/apigw-lambda-rekognition/main.tf @@ -104,6 +104,8 @@ resource "aws_s3_bucket_notification" "s3_bucket_notification" { lambda_function_arn = aws_lambda_function.process_s3_event.arn events = ["s3:ObjectCreated:*"] } + + depends_on = [aws_lambda_permission.allow_s3] } resource "aws_lambda_permission" "allow_s3" { statement_id = "${lower(var.prefix)}-allow-s3-invoke-lambda" From 4ae21c079f82ab969ef83042ee5912ae034b2c4c Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Wed, 24 Dec 2025 10:09:48 +0900 Subject: [PATCH 3/3] apigw-lambda-rekognition: Update README.md --- apigw-lambda-rekognition/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apigw-lambda-rekognition/README.md b/apigw-lambda-rekognition/README.md index 7dd0d0594..faa6701d4 100644 --- a/apigw-lambda-rekognition/README.md +++ b/apigw-lambda-rekognition/README.md @@ -47,13 +47,17 @@ Important: this application uses various AWS services and there are costs associ 1. Make a POST request to the API using the following cURL command: + ``` curl --location 'https://.execute-api..amazonaws.com/dev/generate-presigned-url' --header 'Content-Type: text/plain' --data '{"object_name": "image.png", "content_type": "image/png"}' + ``` Note: Replace 'api-id' with the generated API ID from Terraform, 'region' with the region where the API is deployed (refer to the Terraform Outputs section) 'object_name' with your desired name for the S3 object and 'content_type' with the content type of the image, for ex, png or jpeg 1. Get the pre-signed URL from the previous step and use the following cURL command to upload the object in S3: - curl -v --location --request PUT '' --header 'Content-Type: image/png' --data '.png' + ``` + curl -v --location --request PUT '' --header 'Content-Type: image/png' --data-binary @image.png + ``` Note: Replace 'presigned-url' with pre-signed URL generated in the previous step. 'Content-Type' should match the content type used to generate the pre-signed URL in the previous step. Make sure you are passing the correct path of the object in the --data parameter. @@ -96,4 +100,4 @@ Important: this application uses various AWS services and there are costs associ ---- Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -SPDX-License-Identifier: MIT-0 \ No newline at end of file +SPDX-License-Identifier: MIT-0