AWS API Gateway Model

This page shows how to write Terraform and CloudFormation for API Gateway Model and write them securely.


Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.


Terraform Example (aws_api_gateway_model)

Provides a Model for a REST API Gateway.


Example Usage (from GitHub)

resource "aws_api_gateway_model" "tfer--7g27x7" {
  content_type = "application/json"
  description  = "This is a default empty schema model"
  name         = "Empty"
  rest_api_id  = "0abe4bmm65"
  schema       = "{\n  \"$schema\": \"\",\n  \"title\" : \"Empty Schema\",\n  \"type\" : \"object\"\n}"
resource "aws_api_gateway_model" "machine_config" {
  rest_api_id  =
  name         = "MachineConfig"
  description  = "A configuration returned by /preflight"
  content_type = "application/json"

resource "aws_api_gateway_model" "error_model" {
  rest_api_id  =
  name         = "Error"
  description  = "a JSON schema"
  content_type = "application/json"

resource "aws_api_gateway_model" "result_request" {
  rest_api_id  =
  name         = "ResultRequest"
  content_type = "application/json"

  schema = <<EOF
resource "aws_api_gateway_model" "gateway_model" {
  count        = length(var.gateway_model)
  content_type = lookup(var.gateway_model[count.index], "content_type")
  name         = lookup(var.gateway_model[count.index], "name")
  rest_api_id  = element(var.rest_api_id, lookup(var.gateway_model[count.index], "rest_api_id"))
  schema       = file(join(".", [join("/", [path.cwd, lookup(var.gateway_model[count.index], "schema")]), ".json"]))

CloudFormation Example (AWS::ApiGateway::Model)

The AWS::ApiGateway::Model resource defines the structure of a request or response payload for an API method.


Frequently asked questions

What is AWS API Gateway Model?

AWS API Gateway Model is a resource for API Gateway of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS API Gateway Model?

For Terraform, the denniswed/headsincloud-FO-copy, airbnb/rudolph and mallebris/rest-api-deployment-example source code examples are useful. See the Terraform Example section for further details.