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 diff --git a/apigw-lambda-rekognition/main.tf b/apigw-lambda-rekognition/main.tf index 80aa360cd..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" @@ -145,8 +147,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 +186,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 +}