One limitation that I am facing is that for the generated API gateway based on the openapi spec I would like to add an existing lambda function that exists in my serverless.yml.
For example, I have this lambda that check for authorization:
functions:
authorizerHandler:
name: ${self:service}-authorizer-${sls:stage}
description: Authorizer handler to check incoming requests
handler: src/handler.authorizerHandler
I've also added the code required by the package like below:
openApiIntegration:
inputFile: src/openapi_specs/custom.yml
package: true
cors: true
apiResourceName: ApiGatewayRestApiCustom
mapping:
- stage: [dev, stage, prod] #multiple stages
- path: myPath
And the resource section:
resources:
Resources:
ApiGatewayRestApiCustom: # This resource name must match the default naming
Type: AWS::ApiGateway::RestApi
Properties:
Name: "Custom_openapi"
FailOnWarnings: "true"
Body: ${file(src/openapi_specs/custom.yml)}
I've tried to add an api gateway authorizer like below:
ApiGatewayAuthorizer: # Define an API Gateway Authorizer
Type: AWS::ApiGateway::Authorizer
Properties:
Name: 'custom-authorizer'
Type: TOKEN
IdentitySource: method.request.header.Authorization
AuthorizerUri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${self:service}-authorizer-${self:provider.stage}/invocations
RestApiId:
Ref: ApiGatewayRestApiCustom # Reference to our defined ApiGatewayRestApi
But even with that it generates my api gateway without adding this lambda as the authorizer.
Can you tell me if this is supported in any way by the package?
One limitation that I am facing is that for the generated API gateway based on the openapi spec I would like to add an existing lambda function that exists in my serverless.yml.
For example, I have this lambda that check for authorization:
I've also added the code required by the package like below:
And the resource section:
I've tried to add an api gateway authorizer like below:
But even with that it generates my api gateway without adding this lambda as the authorizer.
Can you tell me if this is supported in any way by the package?