Double, triple, and quadruple check your JSON is a valid for the api body. This error is not very clear, but any issues with your JSON formatting or structure will also cause you to get the same result.
I personally did not define a terraform resource for aws_api_gateway_method or aws_api_gateway_integration in my configuration. Here is an example of what I had for a body and the subtle change that fixed the error.
For context, the goal here was to enable API Gateway to trigger a Lambda Function which means I also had a aws_lambda_permission resource defined that allows invocation of Lambda by API Gateway.
This was throwing Error: Error creating API Gateway Deployment: BadRequestException: No integration defined for method:
locals {
body = jsonencode({
swagger = "2.0"
info = {
title = "Example"
version = "1.0"
}
schemes = [
"https"
]
paths = {
"/path" = {
get = {
responses = {
"200" = {
description = "200 response"
}
}
}
x-amazon-apigateway-integration = {
type = "AWS"
uri = module.lambda.invoke_arn
httpMethod = "POST"
responses = {
default = {
statusCode = 200
}
}
}
}
}
})
}
Correcting the JSON to this allowed the deployment to go through.
locals {
body = jsonencode({
swagger = "2.0"
info = {
title = "Example"
version = "1.0"
}
schemes = [
"https"
]
paths = {
"/path" = {
get = {
responses = {
"200" = {
description = "200 response"
}
} <-- the change is here
x-amazon-apigateway-integration = {
type = "AWS"
uri = module.lambda.invoke_arn
httpMethod = "POST"
responses = {
default = {
statusCode = 200
}
}
}
}
}
}
})
}