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

Viewed 15

how can i add url string query parameter in rest api gateway using terraform


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

please guide me with terraform script to add method request query parameter like HTTP://URL/book?id= .

i want to add query parameter in delete and post method so when in give id, api gateway get request and delete particular data from giving id

thanks..

0 Answers
Related