Amazon web services 使用Cloudformation将API网关与SNS集成

Amazon web services 使用Cloudformation将API网关与SNS集成,amazon-web-services,aws-api-gateway,amazon-cloudformation,Amazon Web Services,Aws Api Gateway,Amazon Cloudformation,我试图使用Cloudformation将API网关方法集成到SNS主题中,但无法理解Uri属性应该是什么样子 要连接到Lambda,它看起来像: "Integration": { "IntegrationHttpMethod": "POST", "Type": "AWS", "Uri": { "Fn::Join": [ "", [ "arn:aws:apigateway:",

我试图使用Cloudformation将API网关方法集成到SNS主题中,但无法理解
Uri
属性应该是什么样子

要连接到Lambda,它看起来像:

"Integration": {
      "IntegrationHttpMethod": "POST",
      "Type": "AWS",
      "Uri": {
        "Fn::Join": [
          "",
          [
            "arn:aws:apigateway:",
            {
              "Ref": "AWS::Region"
            },
            ":lambda:path/2015-03-31/functions/",
            {
              "Fn::GetAtt": [
                "SomeLambdaFunction",
                "Arn"
              ]
            },
            "/invocations"
          ]
        ]
      }

SNS的等价物是什么?

将主题、主题和消息设置为请求参数的集成模板如下所示:

  ApiGatewayGETMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      AuthorizationType: NONE
      HttpMethod: GET
      RequestParameters:
        method.request.querystring.message: false
        method.request.querystring.subject: false
        method.request.querystring.topic: false
      Integration:
        Type: AWS
        Credentials:
          Fn::GetAtt: [ GatewayRole, Arn ]
        Uri:
          Fn::Join:
            - ""
            - - "arn:aws:apigateway:"
              - Ref: AWS::Region
              - ":sns:action/Publish"
        IntegrationHttpMethod: GET
        RequestParameters:
          integration.request.querystring.TopicArn: "method.request.querystring.topic"
          integration.request.querystring.Subject: "method.request.querystring.subject"
          integration.request.querystring.Message: "method.request.querystring.message"
        IntegrationResponses:
          - StatusCode: 200
            ResponseTemplates:
              application/json: '{"status":"OK"}'
      MethodResponses:
        - StatusCode: 200
      ResourceId:
        Fn::GetAtt: [ ApiGatewayRestApi , RootResourceId ]
      RestApiId: !Ref ApiGatewayRestApi
可以使用以下语法调用此实现:

https://abc123456.execute-api.eu-central-1.amazonaws.com/x
          ?topic=arn:aws:sns:eu-central-1:111111:sampletopic
          &message=samplemesage
          &subject=samplesubject

将主题、主题和消息设置为请求参数的集成模板如下所示:

  ApiGatewayGETMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      AuthorizationType: NONE
      HttpMethod: GET
      RequestParameters:
        method.request.querystring.message: false
        method.request.querystring.subject: false
        method.request.querystring.topic: false
      Integration:
        Type: AWS
        Credentials:
          Fn::GetAtt: [ GatewayRole, Arn ]
        Uri:
          Fn::Join:
            - ""
            - - "arn:aws:apigateway:"
              - Ref: AWS::Region
              - ":sns:action/Publish"
        IntegrationHttpMethod: GET
        RequestParameters:
          integration.request.querystring.TopicArn: "method.request.querystring.topic"
          integration.request.querystring.Subject: "method.request.querystring.subject"
          integration.request.querystring.Message: "method.request.querystring.message"
        IntegrationResponses:
          - StatusCode: 200
            ResponseTemplates:
              application/json: '{"status":"OK"}'
      MethodResponses:
        - StatusCode: 200
      ResourceId:
        Fn::GetAtt: [ ApiGatewayRestApi , RootResourceId ]
      RestApiId: !Ref ApiGatewayRestApi
可以使用以下语法调用此实现:

https://abc123456.execute-api.eu-central-1.amazonaws.com/x
          ?topic=arn:aws:sns:eu-central-1:111111:sampletopic
          &message=samplemesage
          &subject=samplesubject