# Lambda 触发器缺少 S3 事件通知：S3 存储桶 'my-bucket' 没有为 Lambda 函数 'my-function' 配置事件通知

- **ID:** `cloud/aws-lambda-s3-event-source-missing-notification`
- **领域:** cloud
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

S3 存储桶未配置事件通知以调用 Lambda 函数，通常是由于手动删除了通知或存储桶策略不正确。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| aws_cli | active | — | — |
| lambda_runtime | active | — | — |
| s3 | active | — | — |

## 解决方案

1. ```
   Use AWS CLI to add the event notification: `aws s3api put-bucket-notification-configuration --bucket my-bucket --notification-configuration file://config.json` where config.json contains: `{"LambdaFunctionConfigurations": [{"LambdaFunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function", "Events": ["s3:ObjectCreated:*"]}]}`
   ```
2. ```
   Check and update the Lambda resource-based policy to allow S3 invoke: `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`
   ```

## 无效尝试

- **** — The console may not create the notification if the bucket already has a notification limit (max 100) or if permissions are insufficient. (50% 失败率)
- **** — The bucket policy is independent of event notifications; the notification itself must be configured via S3 API. (80% 失败率)
