Skip to content

Conversation

@kakakakakku
Copy link
Contributor

Issue #, if available:
N/A

Description of changes:
Hi😀 Thanks for the useful patterns!

While testing apigw-lambda-rekognition, I noticed that the Error: Unsupported argument error occurred. Because aws_api_gateway_deployment does NOT have stage_name argument in latest Terraform AWS Provider. We should use aws_api_gateway_stage.

╷
│ Error: Unsupported argument
│ 
│   on main.tf line 148, in resource "aws_api_gateway_deployment" "deployment":
│  148:   stage_name  = "dev"
│ 
│ An argument named "stage_name" is not expected here.
╵

Check

$ curl --location 'https://6rylrmtfw6.execute-api.ap-northeast-1.amazonaws.com/dev/generate-presigned-url' --header 'Content-Type: text/plain' --data '{"object_name": "image.png", "content_type": "image/png"}'
{"presigned_url": "https://s3.ap-northeast-1.amazonaws.com/xxxxxxxxxxx&Expires=1766540977"}%

$ curl -v --location --request PUT 'https://s3.ap-northeast-1.amazonaws.com/xxxxxxxxxxx&Expires=1766540977' --header 'Content-Type: image/png' --data 'image.png'
* Host s3.ap-northeast-1.amazonaws.com:443 was resolved.
(snip)
< HTTP/1.1 200 OK
(snip)

And more the generate-presigned-url Lambda function call Amazon Rekognition correctly.

image

Thank you😀


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

events = ["s3:ObjectCreated:*"]
}

depends_on = [aws_lambda_permission.allow_s3]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

╷
│ Error: creating S3 Bucket (xxxxx-s3-upload) Notification: operation error S3: PutBucketNotificationConfiguration, https response error StatusCode: 400, RequestID: ZRGV6RJWYEZQXGDX, HostID: hB9Ze5FjoPl01sqeI3/PGRae4EM5YzhB/dKN1oI5V8kUP5c2t1zvsWwsGhHU8D94FtmL2uETUi8=, api error InvalidArgument: Unable to validate the following destination configurations
│ 
│   with aws_s3_bucket_notification.s3_bucket_notification,
│   on main.tf line 101, in resource "aws_s3_bucket_notification" "s3_bucket_notification":
│  101: resource "aws_s3_bucket_notification" "s3_bucket_notification" {
│ 
╵

curl -v --location --request PUT '<presigned-url>' --header 'Content-Type: image/png' --data '<path-of-the-object>.png'
```
curl -v --location --request PUT '<presigned-url>' --header 'Content-Type: image/png' --data-binary @image.png
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: --data '<path-of-the-object>.png' command upload not image file. We should use --data-binary option. I updated it and works good😀

@ellisms
Copy link
Contributor

ellisms commented Jan 7, 2026

Thanks @kakakakakku . One small suggestion since we are already updating this pattern - can you include the full APIGW URL in the outputs? I think it will make this step a little easier:
curl --location 'https://<api-id>.execute-api.<region>.amazonaws.com/dev/generate-presigned-url'

@kakakakakku
Copy link
Contributor Author

@ellisms
Thanks and make sense😀 Please check my latest commit.

I added Terraform output and update testing command use output value directly. It's easy to run the step for AWS Builders!

@ellisms
Copy link
Contributor

ellisms commented Jan 7, 2026

Great, thanks! I'll add this to the publishing queue.

@julianwood julianwood merged commit 94446c6 into aws-samples:main Jan 7, 2026
@kakakakakku kakakakakku deleted the apigw-lambda-rekognition branch January 7, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants