在CloudFormation中描述AWS API Gateway主体映射模板 [英] Describe AWS API Gateway Body Mapping Templates in CloudFormation
问题描述
我仔细阅读了文档,但没有找到解决方法。我有一个具有主体映射模板的API网关方法,如上图所示。
I looked though the documentation but didn't find a way to do this. I have a API Gateway method that has a Body Mapping Template, as in the picture attached.
如何在CloudFormation中映射此模板? (我正在使用JSON)。我添加了 PassthroughBehavior: WHEN_NO_TEMPLATES,但是还没有找到添加Content-Type映射的方法。
How do I map this template in CloudFormation? (I'm using JSON). I added "PassthroughBehavior": "WHEN_NO_TEMPLATES", but haven't found a way to add the Content-Type mapping.
谢谢。
推荐答案
您可以将其作为
You can do this as part of the RequestTemplates
property described here.
它应该看起来像这样:
"APIMethodGet": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"RequestTemplates": {
"application/json": {
"Fn::Join": [
"",
[
"{\n \"StreamName\": \"my-kinesis\"\n",
"\n \"Data\": \"$util.base64encode($input.body)\"\n",
"\n \"PartitionKey\": \"1\"\n}"
]
]
}
},
"PassthroughBehavior": "WHEN_NO_TEMPLATES"
}
}
这篇关于在CloudFormation中描述AWS API Gateway主体映射模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!