We have an API gateway with many routes managed by terraform API gateway resources. As the number of routes increased, it was difficult to manage them from the resources. Hence, we are trying to move it to the body parameter with merge so that the new routes can be added by importing openapi spec with amazon extensions. But the custom lambda authorizer is not getting attached to the method request.
OpenAPI Spec:
openapi_config = {
openapi = "3.0.1"
info = {
title = "im-dev-api-gateway"
version = "1.0"
}
paths = {
"/v1/api/go/data" : {
"post" : {
"parameters" : [{
"name" : "proxy",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string"
}
}],
"responses" : {
"200" : {
"description" : "200 response",
"headers" : {
"Access-Control-Allow-Origin" : {
"schema" : {
"type" : "string"
}
}
},
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Empty"
}
}
}
}
},
"security" : [{
"im-dev-lambda-authorizer" : []
}],
"x-amazon-apigateway-integration" : {
"httpMethod" : "POST",
"uri" : "https://$${stageVariables.LoadBalancerURL}/v1/api/go/data",
"requestParameters" : {
"integration.request.header.X-Auth-Client-ID" : "context.authorizer.x-auth-client-id",
"integration.request.path.proxy" : "method.request.path.proxy",
"integration.request.header.X-Request-ID" : "context.authorizer.x-request-id"
},
"passthroughBehavior" : "when_no_match",
"timeoutInMillis" : 29000,
"type" : "http_proxy"
}
},
"options" : {
"responses" : {
"200" : {
"description" : "200 response",
"headers" : {
"Access-Control-Allow-Origin" : {
"schema" : {
"type" : "string"
}
},
"Access-Control-Allow-Methods" : {
"schema" : {
"type" : "string"
}
},
"Access-Control-Allow-Headers" : {
"schema" : {
"type" : "string"
}
}
},
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Empty"
}
}
}
}
},
"x-amazon-apigateway-integration" : {
"responses" : {
"default" : {
"statusCode" : "200",
"responseParameters" : {
"method.response.header.Access-Control-Allow-Methods" : "'GET,OPTIONS,POST,PUT'",
"method.response.header.Access-Control-Allow-Headers" : "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Auth-Client-ID,X-Request-ID'",
"method.response.header.Access-Control-Allow-Origin" : "'*'"
}
}
},
"requestTemplates" : {
"application/json" : "{\"statusCode\": 200}"
},
"passthroughBehavior" : "never",
"timeoutInMillis" : 29000,
"type" : "mock"
}
}
},
"components" : {
"schemas" : {
"Empty" : {
"title" : "Empty Schema",
"type" : "object"
}
},
"securitySchemes" : {
"im-dev-lambda-authorizer" : {
"type" : "apiKey",
"name" : "Unused",
"in" : "header",
"x-amazon-apigateway-authtype" : "custom",
"x-amazon-apigateway-authorizer" : {
"authorizerUri" : "arn:aws:apigateway:ap-south-1:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-south-1:999999999:function:im-dev-authorizer/invocations",
"authorizerCredentials" : "arn:aws:iam::999999999:role/im-dev-api-gateway-auth-invocation",
"authorizerResultTtlInSeconds" : 0,
"identitySource" : "context.$context.requestId",
"type" : "request"
}
}
}
},
}
}
}