- Mais recentes
- Mais votos
- Mais comentários
Hi, You can use Lambda@Edge to trigger code when a origin response comes back with 404 HTTP Status code, please see: https://aws.amazon.com/about-aws/whats-new/2017/12/lambda-at-edge-now-allows-you-to-customize-error-responses-from-your-origin/ https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-updating-http-responses.html
If you enable cloudtrail data events for your S3 bucket you will very easily generate event for objects that do not exist. Once you have the trail defined you can create an Event Bridge alarm for all trails that contain the following value. "errorCode": "NoSuchKey" This error is written to the trail every time there is a GetObject API call for a Key (In your case an image) that doesn't exist. You can then launch a Lambda as a response to the event.
Thanks for this response. Another thing to look into. I figured there was probably more than 1 way to handle this.
Thanks again for this response. I tried it out but as someone very new to AWS, there just seemed to be a ton of steps I wasn't sure about and ultimately, I couldn't get this working. I'm sure if I spent more time and asked a few more questions, I could and this would be a totally viable answer, However the one before seemed a bit better for my needs and abilities.
Rather than referencing your images in S3 directly, you might be better off front-ending your images with a Lambda function that simply returns them if found, but can handle the "not found" scenario too.
Overall, I like this idea. I'm using Drupal and the provided modules for hooking up the s3 bucket so this might add slightly more debt to the project. But something I'll look into so I understand it batter. Thanks for your response.
Conteúdo relevante
- AWS OFICIALAtualizada há 7 meses
- AWS OFICIALAtualizada há 2 meses
Thanks for this response. Lambda@Edge is something I'm not familiar with, so I will def look into this!
This def seemed to be the way to go since I think we really should have CloudFront in front of the S3 bucket.