Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add URL Query String Parameters in aws api gateway using terraform?

I want to pass account_id in the API like below https://exampleapi.com/dev?account_id=12345

Here is the terraform snippet to create aws api gateway:

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

Thanks in advance.

like image 783
dkakoti Avatar asked Oct 30 '22 05:10

dkakoti


1 Answers

    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"

      request_parameters = {
        "integration.request.querystring.account_id"=true
      }
    }

For more info look at request_parameters field of aws_api_gateway_method resource found at https://www.terraform.io/docs/providers/aws/r/api_gateway_method.html

like image 147
Nulljack Avatar answered Nov 15 '22 07:11

Nulljack