Hi all, I’m configuring CORS for API Gateway and want to set default responses. Does anyone know how to set the default 400 and 500 responses for API Gateway?
I can see there is a aws_api_gateway_gateway_response but that requires a “response_type” and the default responses dont have that,
Thanks,
I was searching for the same answer. This ended up working for me:
resource "aws_api_gateway_gateway_response" "cors" {
rest_api_id = aws_api_gateway_rest_api.lambdas.id
response_type = "DEFAULT_4XX"
response_parameters = {
"gatewayresponse.header.Access-Control-Allow-Origin" = "'${aws_cloudfront_distribution.app.domain_name}'"
"gatewayresponse.header.Access-Control-Allow-Methods" = "'OPTIONS'"
}
}