通过Serverless框架创建EventBridge集成报错:EventBridge-PutEvents不被支持
解决ApiGateway V2集成EventBridge时的「EventBridge-PutEvents is not supported」错误
问题原因
出现该错误的核心原因是负载格式版本配置错误。ApiGateway V2与EventBridge的PutEvents集成要求使用2.0版本的负载格式,而你当前配置的1.0版本不支持该集成子类型。
修正后的配置
将PayloadFormatVersion改为2.0,修正后的完整配置如下:
# Create event bridge integration EventBridgeIntegration: DependsOn: - HttpApiRole Type: AWS::ApiGatewayV2::Integration Properties: ApiId: !Ref HttpApi Description: Event Bridge integration IntegrationType: AWS_PROXY IntegrationSubtype: EventBridge-PutEvents PayloadFormatVersion: 2.0 # 关键修改:将版本改为2.0 CredentialsArn: !GetAtt HttpApiRole.Arn RequestParameters: Detail: $request.body.detail DetailType: $request.body.action Source: $request.body.source EventBusName: !GetAtt EventBus.Name
IAM角色权限验证
同时需确保你的HttpApiRole拥有events:PutEvents权限,示例权限配置参考:
HttpApiRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: apigateway.amazonaws.com Action: sts:AssumeRole Policies: - PolicyName: EventBridgePutEventsPolicy PolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Action: events:PutEvents Resource: !GetAtt EventBus.Arn
额外检查点
- 确保使用的Serverless框架版本支持ApiGateway V2的EventBridge集成(建议升级至最新稳定版)
- 确认AWS账号所在区域支持ApiGateway与EventBridge的直接集成(主流区域均已支持)
内容的提问来源于stack exchange,提问作者Gaurav
相关产品推荐
相关产品推荐

