简体   繁体   English

AWS CDK 如何在网关 lambda 集成的请求模板中嵌入自定义 java 脚本

[英]AWS CDK how to embed custom java script in request template of gateway lambda Integration

From the AWS console we can set java script in integration request template mapping.在 AWS 控制台中,我们可以在集成请求模板映射中设置 java 脚本。 the same can not be set through AWS CDK.同样不能通过 AWS CDK 设置。

Template mapping from api gateway integration request allows to set application/json, with which we can also embed java script code as shown below, Similar way how to achieve in CDK来自api网关集成请求的模板映射允许设置application/json,我们也可以使用它嵌入java脚本代码如下图,类似的方法如何在CDK中实现

{"action": "hello",
#set($inputRoot = $input.path('$'))
"endPoints": [
#foreach($elem in $inputRoot.endPoints)
    {
    #set($headers = $elem.headers)
    #if($headers != "")
        "headers": "$elem.headers",
    #end
    "uri": "$elem.uri",
    "info": "$elem.info"
    }
 #if($foreach.hasNext),#end
 #end
 ]}

This can be handled through programming i am withdrawing this issue.这可以通过编程来处理,我正在撤回这个问题。 we can pass it as string like我们可以将它作为字符串传递

"""
{"action": "hello",
#set($inputRoot = $input.path('$'))
"endPoints": [
#foreach($elem in $inputRoot.endPoints)
    {
    #set($headers = $elem.headers)
    #if($headers != "")
        "headers": "$elem.headers",
    #end
    "uri": "$elem.uri",
    "info": "$elem.info"
    }
 #if($foreach.hasNext),#end
 #end
 ]}
"""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Ansible 将 AWS API 网关集成请求正确设置为 lambda 函数? - How to set AWS API gateway integration request to lambda function correctly using Ansible? aws cdk 将值传递给 lambda 自定义资源 - aws cdk passing values to a lambda custom resource 具有API网关集成的AWS Lambda-访问api名称和http请求的类型 - aws lambda with API gateway integration - accessing api name and type of http request API网关中的AWS Lambda集成响应 - {“message”:“内部服务器错误”} - AWS Lambda Integration Response in API Gateway - {“message”: “Internal server error”} 如何在 AWS-CDK 应用程序中形成没有 cdk synt 和 cdk deploy 的云形成模板? - How to form cloud formation template without cdk synt and cdk deploy in AWS-CDK app? 如何使用 CDK python 将请求参数传递给 Api 网关的 httpintegration - How to pass request parameter to httpintegration for Api Gateway using CDK python 如何配置serverless.yml或AWS API网关或AWS Lambda处理程序以从POST请求读取request.header - How to configure serverless.yml or AWS API gateway or AWS lambda handler to read request.headers from POST request 如何在 AWS CDK 创建的 Python Lambda Function 中安装外部模块? - How to install external modules in a Python Lambda Function created by AWS CDK? AWS CDK API 网关构建库 - AWS CDK API Gateway Construct Library 如何在 AWS lambda 中部署脚本 - How to deploy a script in AWS lambda
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM