S3 refuses to save an event notification for a Lambda function
Unable to validate the following destination configurationsShort answer
When you save a bucket notification, S3 checks the destination first. For Lambda it checks that the function's resource policy lets S3 invoke it from your bucket. If that permission is missing, or the function is in another Region, the whole save fails. Add the permission with lambda add-permission, then save again.
Fix it fast
1Find out which cause you have
Read the function's resource-based policy. If there is no statement for the s3.amazonaws.com principal, S3 has no permission to invoke the function.
aws lambda get-policy --function-name my-function --region us-east-12Match what you see, then jump to its fix
- 1
get-policy shows no statement for the s3.amazonaws.com principalThe Lambda function does not allow S3 to invoke itFix - 2
The function exists and has the right policy, but its ARN shows a Region other than the bucket'sThe function is in a different Region than the bucketFix - 3
The notification file also lists TopicConfigurations or QueueConfigurationsAn SNS topic or SQS queue in the same configuration has no policy for S3Fix
- 1
What does the error look like?
Unable to validate the following destination configurationsInvalidArgument: Unable to validate the following destination configurations
Cause 1 of 3
The Lambda function does not allow S3 to invoke it
1Check
When you create the notification through the API, S3 verifies that the function permissions grant S3 the right to invoke it from your bucket. The console adds this permission for you; the CLI and SDKs do not.
aws lambda get-policy --function-name my-function --query Policy --output text2Fix
Grant the S3 service principal permission, limited to your bucket and your account, then save the notification again.
aws lambda add-permission \
--function-name my-function \
--statement-id s3-invoke \
--action lambda:InvokeFunction \
--principal s3.amazonaws.com \
--source-arn arn:aws:s3:::my-bucket \
--source-account 1111222233333Verify
The policy now lists the s3.amazonaws.com statement, and the notification saves.
aws lambda get-policy --function-name my-function --query Policy --output text
aws s3api put-bucket-notification-configuration --bucket my-bucket --notification-configuration file://notification.jsonConfirmed by docs.aws.amazon.com
Cause 2 of 3
The function is in a different Region than the bucket
1Check
The Lambda function must be in the same Region as the S3 bucket. Compare the Region in the function ARN with the bucket's Region.
aws s3api get-bucket-location --bucket my-bucket
grep LambdaFunctionArn notification.json2Fix
Create or copy the function in the bucket's Region and use that ARN in LambdaFunctionArn.
{
"LambdaFunctionConfigurations": [
{
"LambdaFunctionArn": "arn:aws:lambda:us-east-1:111122223333:function:my-function",
"Events": ["s3:ObjectCreated:*"]
}
]
}3Verify
Apply the file and read the configuration back.
aws s3api put-bucket-notification-configuration --bucket my-bucket --notification-configuration file://notification.jsonConfirmed by docs.aws.amazon.com
Cause 3 of 3
An SNS topic or SQS queue in the same configuration has no policy for S3
1Check
The PUT is atomic. S3 sends a test message to each SNS and SQS destination, and if one fails the whole request fails, including the Lambda part.
grep -E "TopicArn|QueueArn" notification.json2Fix
Attach an access policy to the topic or queue that lets s3.amazonaws.com publish, limited by aws:SourceArn to your bucket.
{
"Effect": "Allow",
"Principal": { "Service": "s3.amazonaws.com" },
"Action": "SQS:SendMessage",
"Resource": "arn:aws:sqs:us-east-1:111122223333:queue-name",
"Condition": {
"ArnLike": { "aws:SourceArn": "arn:aws:s3:*:*:my-bucket" },
"StringEquals": { "aws:SourceAccount": "111122223333" }
}
}3Verify
Apply the full notification file again.
aws s3api put-bucket-notification-configuration --bucket my-bucket --notification-configuration file://notification.jsonConfirmed by docs.aws.amazon.com
How do I stop it coming back?
- Define the bucket notification and the Lambda permission together in the same infrastructure template, with the permission created first.
- Always set source-arn and source-account on the permission so no other account's bucket can invoke the function.
- Keep the bucket and the function in one Region.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- RaheebA consumer app shipped to both stores from one Flutter codebase on a .NET and Azure back end.
- Loade DriverThe driver side of a delivery platform: live jobs, routing and earnings, past 5K Google Play downloads.
Related fixes
Back end
API Gateway gives up on a slow Lambda or Node.js backend
$context.integrationErrorMessage in the access log shows the integration error
API Gateway stops waiting for the backend at its integration timeout: 29 seconds by default on REST APIs, a fixed 30 seconds on HTTP APIs.
4 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
cdk synth says --app is required
--app is required either in command-line, in cdk.json or in ~/.cdk.json
The CDK CLI needs a command that runs your app and finds it in three places: the --app option, cdk.json in the project folder, or cdk.json in your home folder.
3 causes, each with a fixBack end
The AWS SDK for Java cannot find credentials, and AwsCredentials.properties does nothing
software.amazon.awssdk.core.exception.SdkClientException: Unable to load credentials from any of the providers in the chain
AwsCredentials.properties on the classpath is an old convention: the default provider chain of the AWS SDK for Java does not read it.
4 causes, each with a fixBack end
The AWS SDK in Node.js cannot find any credentials
Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
The AWS SDK walks a fixed credential chain: code, environment variables, the shared files in ~/.aws, then role sources such as ECS or EC2.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fix