dka*_*oti 5 api amazon-web-services terraform
我想在 API 中传递 account_id,如下所示https://exampleapi.com/dev?account_id=12345
这是创建 aws api 网关的 terraform 片段:
resource "aws_api_gateway_method" "example_api_method" {
rest_api_id = "${aws_api_gateway_rest_api.example_api.id}"
resource_id = "${aws_api_gateway_resource.example_api_resource.id}"
http_method = "GET"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "example_api_method-integration" {
rest_api_id = "${aws_api_gateway_rest_api.example_api.id}"
resource_id = "${aws_api_gateway_resource.example_api_resource.id}"
http_method = "${aws_api_gateway_method.example_api_method.http_method}"
type = "AWS"
uri = "arn:aws:apigateway:${var.aws_region}:lambda:path/functions/${var.lambda_arn}/invocations"
integration_http_method = "GET"
}
Run Code Online (Sandbox Code Playgroud)
提前致谢。
在此集成资源上,您可以使用request_templates参数并使用输入变量。如果你添加了喜欢的东西
resource "aws_api_gateway_integration" "example_api_method-integration" {
rest_api_id = "${aws_api_gateway_rest_api.example_api.id}"
resource_id = "${aws_api_gateway_resource.example_api_resource.id}"
http_method = "${aws_api_gateway_method.example_api_method.http_method}"
type = "AWS"
uri = "arn:aws:apigateway:${var.aws_region}:lambda:path/functions/${var.lambda_arn}/invocations"
integration_http_method = "GET"
request_templates = {
"application/json" = <<EOF
{
"account_id": "$util.escapeJavaScript($input.params().querystring.get("account_id))"
}
EOF
}
}
Run Code Online (Sandbox Code Playgroud)
在您的 terraform 中,您将获得一个名为 account_id 的查询字符串,并将其添加到您的事件中。输入变量文档中还有一个示例,显示如何解压查询字符串键下的所有查询字符串。
| 归档时间: |
|
| 查看次数: |
3599 次 |
| 最近记录: |