我正在尝试使用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的等价物是什么样的?
答案 0 :(得分:0)
将主题,主题和消息设置为请求参数的集成模板如下所示:
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