简体   繁体   中英

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. the same can not be set through 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

{"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
 ]}
"""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM