Skip to content
This repository was archived by the owner on Jul 16, 2022. It is now read-only.

Implement Lambda warmer #2

Open
wants to merge 1 commit into
base: netcore-22-runtime-upgrade
Choose a base branch
from

Conversation

michaeldimoudis
Copy link
Owner

No description provided.

@bsthomsen
Copy link

bsthomsen commented Jul 29, 2019

Hey @michaeldimoudis, what if you were to use the Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction. How would you implement this, it doesn't seem to have request.Resource Would you then just dissect the json body and check if it's a lambda warmer request?

@michaeldimoudis
Copy link
Owner Author

Hi @bsthomsen I'm not sure sorry as I haven't had to do this before. I'm guessing it should be possible though? However if you are using an ALB, why not make the health check your Lambda so you won't need a warmer then?

@bsthomsen
Copy link

Ended up resolving it like this, for ApplicationLoadBalancer:
https://gist.github.com/bsthomsen/f6397b1e171b91387c2a65bfb05169c5

@richardkeller411
Copy link

Thanks @bsthomsen!! I’ll try it out!

@richardkeller411
Copy link

I got your code to work but somehow cannot get a response correctly from the modified Lambda although routing and methods fire.

Method:

[HttpGet("get")]
[ProducesResponseType(typeof(void), (int)HttpStatusCode.BadRequest)]
public IActionResult Get()
{
LambdaLogger.Log("Test Get Fired");
return StatusCode(500, "TestAPI returned GET");
}

Logs:


04:23:13
Request does not contain ELB information but is derived from ApplicationLoadBalancerFunction.

04:23:13
[Debug] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: ASP.NET Core Request PathBase: , Path: /api/test/get

04:23:13
ASP.NET Core Request PathBase: , Path: /api/test/get

04:23:13
Test Get Fired

04:23:13
[Debug] Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction: Response Base 64 Encoded: False

I am trying to fire through the ApplicationGateway vs the ALB but thought methods should return anyways.

@bsthomsen
Copy link

@richardkeller411 if you use the ApiGateway you should use the code in this pull request instead. The code I wrote is for when you're using ApplicationLoadBalancer.

@richardkeller411
Copy link

I’m using ALB but can’t seem to get response to return although I have the method firing and see it in the Post Method overloads that I have logging. The APIGateway message is part of the SDK logging from the ALB method

@bsthomsen
Copy link

@richardkeller411 you need to update your LambdaEntryPoint to reflect the other class I posted, I've added it to the gist so you can see how I did it:
https://gist.github.com/bsthomsen/f6397b1e171b91387c2a65bfb05169c5#file-lambdaentrypoint-cs

@richardkeller411
Copy link

I did that already.

@richardkeller411
Copy link

For anyone else looking at ALB... You need to make sure security groups account for HTTP Traffic Inbound and if you method connects to a Database or External HTTP call you need to have your VPC setup right with NAT Gateway and DB Internal Ports.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants