繁体   English   中英

如何使用 terraform 在 api 网关中添加 url 查询字符串参数

[英]how to add url query string parameter in api gateway using terraform

如何在 rest api 网关中添加 url 字符串查询参数


resource "aws_api_gateway_rest_api" "students" {
  body = jsonencode({
    openapi = "3.0.1"
    info = {
      title   = var.rest_api_name
      version = "1.0"
    }
    paths = {
      (var.rest_api_path) = {
        get = {
          x-amazon-apigateway-integration = {
            httpMethod           = "GET"
            payloadFormatVersion = "1.0"
            type                 = "HTTP_PROXY"
            uri                  = "${var.url}/students"
          }
          
        },
        post = {
          x-amazon-apigateway-integration = {
            httpMethod           = "POST"
            payloadFormatVersion = "1.0"
            type                 = "HTTP_PROXY"
            uri                  = "${var.url}/students"
          }
        },
        put = {
          x-amazon-apigateway-integration = {
            httpMethod           = "PUT"
            payloadFormatVersion = "1.0"
            type                 = "HTTP_PROXY"
            uri                  = "${var.url}/students"
            request_parameters = {
              "integration.request.querystring.id"=true
            }
          }
        },
        delete = {
          x-amazon-apigateway-integration = {
            httpMethod           = "DELETE"
            payloadFormatVersion = "1.0"
            type                 = "HTTP_PROXY"
            uri                  = "${var.url}/students"
          
            request_parameters = {
              "integration.request.querystring.id"=true
            }
        }
      }
    }
      
    } 
  })
  name = var.rest_api_name
  endpoint_configuration {
    types = ["REGIONAL"]
  }
}

请指导我使用 terraform 脚本添加方法请求查询参数,如 HTTP://URL/book?id=

我想在删除和发布方法中添加查询参数,所以当在给 id 时,api 网关获取请求并从给定 id 中删除特定数据

谢谢..

暂无
暂无

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

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