gpt4 book ai didi

amazon-web-services - AWS API Gateway 与 Cloudformation 脚本中的 AWS Event Bridge(Cloudwatch Events) 集成

转载 作者:行者123 更新时间:2023-12-03 07:13:24 30 4
gpt4 key购买 nike

原始要求:

在 AWS Api Gateway 上创建一条路由/路径,将 API Gateway 直接连接到 AWS Event Bridge(Cloudwatch Events),并将事件放置/推送到其事件总线上。

能够创建它并在从 AWS 控制台完成后执行得很好。

实际问题:

为此 API 网关编写 AWS Cloudformation 脚本时,如下所示:

EventsPostMethod:
Type: AWS::ApiGateway::Method
Properties:
ResourceId:
Ref: EventsResource
RestApiId:
Ref: RestAPI
HttpMethod: POST
AuthorizationType: NONE
Integration:
Type: AWS
IntegrationHttpMethod: POST
Uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:cloudwatchEvents:action/PutEvents
RequestParameters:
integration.request.header.X-Amz-Target: "'AWSEvents.PutEvents'"
RequestTemplate:
some-script-here...

注意 Uri 值:

"arn:aws:apigateway:${AWS::Region}:cloudwatchEvents:action/PutEvents"
arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}

根据 AWS Docs uri 的值应如下:

For AWS or AWS_PROXY integrations, the URI is of the form arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}. Here, {Region} is the API Gateway region (e.g., us-east-1); {service} is the name of the integrated AWS service (e.g., s3); and {subdomain} is a designated subdomain supported by certain AWS service for fast host-name lookup. action can be used for an AWS service action-based API, using an Action={name}&{p1}={v1}&p2={v2}... query string. The ensuing {service_api} refers to a supported action {name} plus any required input parameters. Alternatively, path can be used for an AWS service path-based API. The ensuing service_api refers to the path to an AWS service resource, including the region of the integrated AWS service, if applicable. For example, for integration with the S3 API of GetObject, the uri can be either arn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key} or arn:aws:apigateway:us-west-2:s3:path/{bucket}/{key}

您一定已经注意到,我在上述 uri 中将 service 替换为 cloudwatchEvents

现在,AWS Cloudformation 控制台在发布 API Gateway 期间给出错误:

AWS Service of type cloudwatchEvents not supported (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 07bae22c-d198-4595-8de9-6ea23763eff5; Proxy: null)

现在我尝试用以下内容替换服务

  • 云观察
  • 事件桥
  • cloudwatch事件
  • 事件总线

这才是真正的问题。我应该在 uri 中放置什么服务才能接受?

enter image description here

最佳答案

根据评论,

事件的 URI 应类似于以下内容:

arn:aws:apigateway:${AWS::Region}:events:action/PutEvents

关于amazon-web-services - AWS API Gateway 与 Cloudformation 脚本中的 AWS Event Bridge(Cloudwatch Events) 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66275505/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com