在CloudFormation中描述AWS API Gateway主体映射模板 [英] Describe AWS API Gateway Body Mapping Templates in CloudFormation

查看:81
本文介绍了在CloudFormation中描述AWS API Gateway主体映射模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仔细阅读了文档,但没有找到解决方法。我有一个具有主体映射模板的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.

谢谢。

推荐答案

您可以将其作为RequestTemplates 属性的一部分进行操作/docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-method-integration.html#cfn-apigateway-method-integration-passthroughbehavior rel = nofollow noreferrer>此处。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆