Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Latest commit

 

History

History
50 lines (41 loc) · 1.65 KB

README.md

File metadata and controls

50 lines (41 loc) · 1.65 KB

This module creates an API gateway method under a given path.

See the variables.tf file in the module folder for more information on the module parameters. Most of these parameters are directly passed to the corresponding Terraform resource. The documentation for integration resources and integration response resources contains information on the module parameters such as request.template or responses.template.

Example

resource "aws_api_gateway_rest_api" "api" {
 name = "${var.prefix}ApiMethod"
}

module "sample_method" {
  source = "git::https://github.com/vistaprint/terraformmodules.git//modules/api_method"
  api    = aws_api_gateway_rest_api.api.id
  parent = aws_api_gateway_rest_api.api.root_resource_id
  querystrings = {
    q = true
  }
  request = {
    type = "MOCK"
    content_type = "application/json"
    template = <<EOF
{"statusCode": #if($input.params('q')=="existing")200#{else}404#end}
EOF
  }
  passthrough_behavior = "NEVER"
  responses = {
    "200" = {
      content_type = "text/plain"
      selection_pattern = ""
      template = "Found"
    }
    "404" = {
      content_type = "text/plain"
      selection_pattern = "404"
      template = "Not found"
    }
  }
}

Limitations

  • Only works for GET methods

Usage Guidelines

Response Content Type

The default response content type is application/json, but this can be overridden by using the response_content_type variable (as shown in the example).