以下是一些代码示例:
在API Gateway的“Integration Request”页面中,将下面的模板添加到“Body Mapping Templates”字段中,以将查询字符串传递到后端服务(NLB):
{ "queryStringParameters": { #foreach($queryParam in $input.params().querystring.keySet()) "$queryParam": "$util.escapeJavaScript($input.params().querystring.get($queryParam))" #if($foreach.hasNext),#end #end } }
在API Gateway的“Deployment”页面中,将下面的代码添加到“Stage variables”字段中,以使用NLB的DNS名称更新“Invoke URL”:
{ "NLB_ENDPOINT": "your-nlb-dns-name" }
在NLB的目标组中,将下面的代码添加到“Health check settings”字段中,以启用健康检查:
{ "protocol": "HTTP", "path": "/health", "port": "80", "healthyThresholdCount": 2, "unhealthyThresholdCount": 2, "intervalSeconds": 10, "timeoutSeconds": 5 }