# CloudWatch alarm: S3 Object Lambda LambdaResponse4xx

CloudWatch alarms · Updated 16 November 2026

**Short answer:** Alarm on AWS/S3ObjectLambda LambdaResponse4xx for the AccessPointName and DataSourceARN, Average over 60 seconds, above 0.05 for 15 of 15 minutes. It counts client errors S3 returned to your transformation function when it called WriteGetObjectResponse, which points at a bug or permission problem in the function rather than in the caller.

## What this metric isolates

The other Object Lambda error metrics describe what the end client received. `LambdaResponse4xx` looks one step inside: it measures 4xx responses S3 gave to the *function's* `WriteGetObjectResponse` call. When that call fails, the transformed object never reaches the client, who then sees an error too.

Typical reasons for a 4xx on that call:

- The function's execution role lacks permission to call `WriteGetObjectResponse` (the `s3-object-lambda:WriteGetObjectResponse` action).
- The function passes the wrong `RequestRoute` or `RequestToken` from the event, for example from a different invocation or a hard-coded value.
- Invalid response parameters: headers or metadata S3 rejects.
- The function responds too late, after the request has already been abandoned.

Because these are code or configuration problems, they tend to appear right after a deploy and affect every request, rather than trickling in.

The route and token come from the invocation event. A minimal correct pattern in Python looks like this:

```
def handler(event, context):
    ctx = event["getObjectContext"]
    original = requests.get(ctx["inputS3Url"]).content
    s3.write_get_object_response(
        RequestRoute=ctx["outputRoute"],
        RequestToken=ctx["outputToken"],
        Body=transform(original),
    )
```

Reusing values across invocations, or reading them from the wrong key, is a common way to end up with every call rejected.

## Recommended alarm settings

| Setting | Recommended value |
|---|---|
| Namespace | `AWS/S3ObjectLambda` |
| Metric | `LambdaResponse4xx` |
| Dimensions | AccessPointName, DataSourceARN |
| Statistic | Average |
| Threshold | 0.05 |
| Period | 60 seconds |
| Datapoints to alarm | 15 |
| Evaluation periods | 15 |
| Comparison operator | `GreaterThanThreshold` |

## Tuning

A healthy function should produce essentially no `LambdaResponse4xx`. The 5% threshold and 15-minute window are conservative; if the access point serves real users, consider lowering both so a broken deploy pages you within minutes. Keep missing data as not breaching for access points with idle periods.

Test changes with a single request through the access point before deploying broadly: a malformed `WriteGetObjectResponse` call fails on the first request, so it is cheap to catch in a staging environment.

## Create the alarm

```
aws cloudwatch put-metric-alarm \
  --alarm-name s3ol-redacted-docs-lambda-response-4xx \
  --alarm-description "Transformation function getting 4xx from WriteGetObjectResponse" \
  --namespace AWS/S3ObjectLambda \
  --metric-name LambdaResponse4xx \
  --dimensions Name=AccessPointName,Value=redacted-docs Name=DataSourceARN,Value=arn:aws:s3:eu-west-2:123456789012:accesspoint/docs-ap \
  --statistic Average \
  --period 60 \
  --evaluation-periods 15 \
  --datapoints-to-alarm 15 \
  --threshold 0.05 \
  --comparison-operator GreaterThanThreshold \
  --treat-missing-data notBreaching \
  --alarm-actions arn:aws:sns:eu-west-2:123456789012:oncall-alerts
```

## When it fires

1. **Read the function's logs.** The SDK error from `WriteGetObjectResponse` names the problem (access denied, invalid token, invalid argument).
2. **Check the role** for the `WriteGetObjectResponse` permission, especially if the role or its policies changed recently.
3. **Check the code path** that reads `getObjectContext` from the event, and confirm both route and token are passed through unchanged.
4. **Roll back** the function version if the alarm started with a deploy.

## Questions

### How do I create a CloudWatch alarm for an S3 bucket?

Enable request metrics on the bucket with a metrics configuration (a filter), then alarm on metrics such as 4xxErrors or 5xxErrors using the BucketName and FilterId dimensions. Daily storage metrics like BucketSizeBytes need no setup but are only updated once a day.

### What is the difference between 4xxErrors and LambdaResponse4xx?

4xxErrors counts client errors returned to the end caller. LambdaResponse4xx counts client errors S3 returned to your function when it tried to send the transformed response.

## When this happens away from your desk

Errors on the function's response call usually start with a deploy and affect every request, so speed matters. CloudConsole, a phone app for AWS, is built to show the alarm on your phone as soon as it changes state.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Recommended alarms (Amazon CloudWatch User Guide)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html)
- [Transforming objects with S3 Object Lambda](https://docs.aws.amazon.com/AmazonS3/latest/userguide/transforming-objects.html)
- [Amazon S3 CloudWatch metrics and dimensions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/metrics-dimensions.html)

## Related

- [CloudWatch alarm: S3 Object Lambda 4xxErrors](https://cloudconsole.dev/alarms/s3-object-lambda-4xxerrors)
- [CloudWatch alarm: S3 Object Lambda 5xxErrors](https://cloudconsole.dev/alarms/s3-object-lambda-5xxerrors)
- [CloudWatch alarm: Lambda Errors](https://cloudconsole.dev/alarms/lambda-errors)
- [How to roll back a Lambda version](https://cloudconsole.dev/how-to/roll-back-lambda-version)
- [aws lambda get-function](https://cloudconsole.dev/cli/lambda-get-function)

---

Source: https://cloudconsole.dev/alarms/s3-object-lambda-lambdaresponse4xx

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
