微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AWS S3创建错误:“通知不支持该事件服务:Amazon S3;状态代码:400;错误代码:InvalidArgument”

如何解决AWS S3创建错误:“通知不支持该事件服务:Amazon S3;状态代码:400;错误代码:InvalidArgument”


我正在Code9中开发我的第一个lambda,它可能是由S3事件触发的。不幸的是,当我尝试进行部署时,我不断收到CloudFormation错误

"The event is not supported for notifications (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: CF3108325F3C9B60; S3 Extended Request ID: wcWzRXUu7YJn/BVnPDtOx7yBHllhIPELEwsTweqVcfwLw1hkR2idismQbxeL3Hrtp7Kv58ujS2s=; Proxy: null)"


请参阅以下来自AWS Mgm控制台的CloudFormation事件:

enter image description here

下面是我的AWS SAM template.yaml文件

AWstemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Serverless Specification template describing your function.
Resources:
  olatexOrdersInputDirectory:
    Type: 'AWS::S3::Bucket'
  olatexXlsxOrderLoader:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: olatexXlsxOrderLoader/index.handler
      Runtime: nodejs12.x
      Description: ''
      MemorySize: 128
      Timeout: 15
      Policies:
      - AWSLambdaBasicExecutionRole
      - AmazonS3FullAccess
      - AmazonDynamoDBFullAccess
      Events:
        S3Event:
          Type: S3
          Properties:
            Bucket: !Ref olatexOrdersInputDirectory
            Events: S3:ObjectCreated:*

我在Policies:之后添加了几行,以扩展IAM策略,因为我怀疑错误与特权不足有关,但无济于事。
在下面,我将附加从SAM的template.yaml生成的CloudFormation模板:

{
  "AWstemplateFormatVersion": "2010-09-09","Description": "An AWS Serverless Specification template describing your function.","Resources": {
    "olatexXlsxOrderLoader": {
      "Type": "AWS::Lambda::Function","Properties": {
        "Code": {
          "S3Bucket": "cloud9-026528720964-sam-deployments-eu-central-1","S3Key": "6aa2a5885a77ea790684cb345d822ed8"
        },"Description": "","Tags": [
          {
            "Value": "SAM","Key": "lambda:createdBy"
          }
        ],"MemorySize": 128,"Handler": "olatexXlsxOrderLoader/index.handler","Role": {
          "Fn::GetAtt": [
            "olatexXlsxOrderLoaderRole","Arn"
          ]
        },"Timeout": 15,"Runtime": "nodejs12.x"
      }
    },"olatexXlsxOrderLoaderRole": {
      "Type": "AWS::IAM::Role","Properties": {
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17","Statement": [
            {
              "Action": [
                "sts:AssumeRole"
              ],"Effect": "Allow","Principal": {
                "Service": [
                  "lambda.amazonaws.com"
                ]
              }
            }
          ]
        },"ManagedPolicyArns": [
          "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole","arn:aws:iam::aws:policy/AmazonS3FullAccess","arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
        ],"Key": "lambda:createdBy"
          }
        ]
      }
    },"olatexOrdersInputDirectory": {
      "Type": "AWS::S3::Bucket","Properties": {
        "NotificationConfiguration": {
          "LambdaConfigurations": [
            {
              "Function": {
                "Fn::GetAtt": [
                  "olatexXlsxOrderLoader","Arn"
                ]
              },"Event": "S3:ObjectCreated:*"
            }
          ]
        }
      },"DependsOn": [
        "olatexXlsxOrderLoaderS3EventPermission"
      ]
    },"olatexXlsxOrderLoaderS3EventPermission": {
      "Type": "AWS::Lambda::Permission","Properties": {
        "Action": "lambda:InvokeFunction","SourceAccount": {
          "Ref": "AWS::AccountId"
        },"FunctionName": {
          "Ref": "olatexXlsxOrderLoader"
        },"Principal": "s3.amazonaws.com"
      }
    }
  }
}

非常感谢您的帮助!
问候
安德烈(Andrzej)

解决方法

基于评论。

此问题是由使用S3:ObjectCreated:*而不是s3:ObjectCreated:*引起的。

S3事件名称是区分大小写的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。