Provides an API Gateway Gateway Response for a REST API Gateway.
resource "aws_api_gateway_rest_api" "main" {
name = "MyDemoAPI"
}
resource "aws_api_gateway_gateway_response" "test" {
rest_api_id = aws_api_gateway_rest_api.main.id
status_code = "401"
response_type = "UNAUTHORIZED"
response_templates = {
"application/json" = "{\"message\":$context.error.messageString}"
}
response_parameters = {
"gatewayresponse.header.Authorization" = "'Basic'"
}
}
This resource supports the following arguments:
rest_api_id
- (Required) String identifier of the associated REST API.response_type
- (Required) Response type of the associated GatewayResponse.status_code
- (Optional) HTTP status code of the Gateway Response.response_templates
- (Optional) Map of templates used to transform the response body.response_parameters
- (Optional) Map of parameters (paths, query strings and headers) of the Gateway Response.This resource exports no additional attributes.
In Terraform v1.5.0 and later, use an import
block to import aws_api_gateway_gateway_response
using REST-API-ID/RESPONSE-TYPE
. For example:
import {
to = aws_api_gateway_gateway_response.example
id = "12345abcde/UNAUTHORIZED"
}
Using terraform import
, import aws_api_gateway_gateway_response
using REST-API-ID/RESPONSE-TYPE
. For example:
% terraform import aws_api_gateway_gateway_response.example 12345abcde/UNAUTHORIZED