I am trying to set an already existing authorizer function on my .Net Core Web API app. When I use purely aws lambda nodejs, the .yml file to accomplish it, looks like this:
custom:
defaultStage: test
currentStage: ${opt:stage, self:custom.defaultStage}
defaultRegion: us-east-1
currentRegion: ${opt:region, self:custom.defaultRegion}
**defaultAuthorizer**: us-east-1:xxxxxxxx:function:TypeToken-test-Authorizer
**currentAuthorizer**: ${opt:authorizer, self:custom.defaultAuthorizer}
provider:
name: aws
runtime: nodejs6.10
stage: ${self:custom.currentStage}
profile: ${opt:profile, "default"}
region: ${self:custom.currentRegion}
functions:
MyFunctionName:
handler: handlerTestAPI.myFunctionName
events:
- http:
path: myFunctionName
method: post
cors: true
integration: lambda
**authorizer:**
arn: arn:aws:lambda:${self:custom.currentAuthorizer}
resultTtlInSeconds: 0
identitySource: method.request.header.Authorization
type: token
For this case, the ASP.NET Core App serverless.template file is similar to this:
“Resources” : {
"AspNetCoreFunction" : {
"Type" : "AWS::Serverless::Function",
"Properties": {
"Handler": "Test.API::Project.API.LambdaEntryPoint::FunctionHandlerAsync",
"Runtime": "dotnetcore2.1",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [ "AWSLambdaFullAccess" ],
"Environment" : {
"Variables" : {
"TestTable" : { "Fn::If" : ["CreateProjectTable", {"Ref":"ProjectTable"}, { "Ref" : "ProjectTableName" } ] }
}
},
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/{proxy+}",
"Method": "ANY"
}
}
}
}
}
I have searched for templates where an existing authorizer is set on top of a .net core
serverless function using serverless.template file, but haven’t found one yet.
May you tell me how to include the configuration entries so I can set the already existing authorizer for my API endpoint in the serverless.template file?
Thanks for the help