News for hackers. Stuff that matters.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by alexellisuk on Tuesday February 27, 2018 @03:34AM (#16471938)
Kind of a shame to have to hack on the source-code and inject a new URL - would have been better to have used a parameter. Anyway - here's how to do it with OpenFaaS and Python from August 2017 :-) https://blog.alexellis.io/first-faas-python-function/
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by mrmondo on Tuesday February 27, 2018 @04:32AM (#16472174)
Much nicer example I think and no AWS tax / lock-in.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by dblooman on Tuesday February 27, 2018 @07:30AM (#16472823)
What are the main benefits of using OpenFaaS except for vendor lock in? 99% of the time, I want a kinesis stream, or S3 event to start my lambdas, which it seems I would have to wire up myself
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by joosters on Tuesday February 27, 2018 @03:23AM (#16471890)
An actual ping would be more impressive :)

Perhaps to be less wasteful, the HTTP request should be a HEAD instead of GET? There’s little point downloading a whole page if you are going to just throw away the contents...

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by laci27 on Tuesday February 27, 2018 @04:42AM (#16472206)
actually, it's not. We create a special page, with PHP and one with nodejs, that just replies '1', so besides status, we also get a notice if nodejs or PHP malfunctions (which does happen on some servers, 1-2 time a year).
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by giancarlostoro on Tuesday February 27, 2018 @09:02AM (#16473375)
HEAD is still less wasteful and just as effective.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by mbrumlow on Tuesday February 27, 2018 @10:02AM (#16473866)
You can still do all that with HEAD, the only difference is you don't return a message body, thus saving 1 byte plus a few in the actual header you would not need any more.

For example; you would do a head request and node.js and php would still need to be configured to handled the HEAD request but instead of its handler returning "1" it would simply return.

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by sonaltr on Monday February 26, 2018 @09:42PM (#16470726)
Looks nice!

1. Why go? (nothing wrong with it in itself, but last I had checked (before go on lambda was released)...Python was supposed the fastest of the bunch available)

1 a. Python can be embedded into a CF template...meaning deployment is slightly nicer (maybe not recommended though?)

2. I think the ability to change the time (20 secs) based on an SSM parameter would be cool!

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by frankcash on Monday February 26, 2018 @10:22PM (#16470858)
1. I chose go since Lambda support was recently added for it. I have a lot of experience using Python and Node.js with Lambdas.

2. Sorry, I include the "20 Seconds" as a symbol of how easy it is to deploy!

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by isuckatcoding on Monday February 26, 2018 @10:35PM (#16470891)
Pretty neat. Instead of hard coding the url, you could provide it as parameter to the main. Pretty sure it’s possible (at least using the node and c# Lambda it was).
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by RileyJames on Monday February 26, 2018 @10:49PM (#16470940)
url could be set via an environmental variable: https://docs.aws.amazon.com/lambda/latest/dg/go-programming-...
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by frankcash on Monday February 26, 2018 @10:38PM (#16470902)
I could definitely look into this, thanks for the suggestion!
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by davewongillies on Monday February 26, 2018 @11:31PM (#16471091)
I raised a PR to just that: https://github.com/frankcash/go-lambda-ping/pull/1

The URL is set in terraform.tfvars, which then gets passed to the lambda resource.

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by ericfrederich on Tuesday February 27, 2018 @11:22AM (#16474881)
I'm curious about how AWS handles lambdas written in Go. Go produces statically linked Linux binaries. What is it about Go that is supported? What is it about binaries written in other languages that isn't supported?
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by nickromano on Tuesday February 27, 2018 @10:19PM (#16480428)
I built a python version recently, it uses the serverless library to deploy to AWS. https://github.com/nickromano/serverless-ping
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by ivanhoe on Tuesday February 27, 2018 @06:55AM (#16472677)
What's approx. monthly cost of running something like this on lambda e.g. every 5 minutes?
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by alexellisuk on Tuesday February 27, 2018 @07:21AM (#16472791)
If you want to access it over HTTP you will have to pay for "AWS API Gateway" which is not free.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by misframer on Tuesday February 27, 2018 @09:21AM (#16473539)
API Gateway isn't much at that rate.

(1 month) / (5 minutes) = 8760

"$3.50 per million API calls received, plus the cost of data transfer out, in gigabytes." [0]

8760 * ($3.50 / 1000000) = $0.03.

[0] https://aws.amazon.com/api-gateway/pricing/

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by codegladiator on Tuesday February 27, 2018 @07:18AM (#16472767)
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by laci27 on Tuesday February 27, 2018 @03:02AM (#16471808)
This is amazing! Does anyone know a good resource to learn more about Lambda and how to setup small projects like this?
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by nzoschke on Tuesday February 27, 2018 @06:58AM (#16472691)
I’m working on a comprehensive resource for running Lambda Go projects here:

https://github.com/nzoschke/gofaas

The guide on periodicnworker functions is how I would build this pinger.

https://github.com/nzoschke/gofaas/blob/master/docs/worker-f...

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by dpeck on Monday February 26, 2018 @10:43PM (#16470921)
Dumb question, never used lambda before, how often is this triggered? I can’t tell at first look through the code.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by shironineja on Monday February 26, 2018 @10:45PM (#16470928)
The lambda doesn't have a schedule within because doing so would split the concerns poorly; rather you would hit this lambda on your own schedule.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by dpeck on Monday February 26, 2018 @10:46PM (#16470929)
Ah, so you ping the lambda to have it ping the coded in website?
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by mali9 on Monday February 26, 2018 @10:55PM (#16470965)
Or you could invoke the lambda on a schedule using Cloudwatch

https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-...

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by frankcash on Monday February 26, 2018 @11:16PM (#16471041)
Yup! Didn't want to include the TF to do the scheduling (for simplicity) but I could add it if people want.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by shironineja on Monday February 26, 2018 @10:47PM (#16470934)
.. as a service!
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by ohyoutravel on Monday February 26, 2018 @09:50PM (#16470761)
Nice! Is there a use case for this, or is this just a go/terraform example? Either way, pretty cool!
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by frankcash on Monday February 26, 2018 @10:21PM (#16470856)
I created this as a terraform example and chose go since it was recently added to Lambda.

I have a personal use case of this: pinging my heroku "dev" tier instance so it stays alive a bit longer.

Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by tamrix on Monday February 26, 2018 @08:53PM (#16470565)
That's a bit long really.
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by spraak on Tuesday February 27, 2018 @12:56AM (#16471381)
That's not the function invocation time (i.e. cold start etc) but rather time to build and deploy (and then maybe imvoke?)
Re:Show HN: Deploy a Go Lambda to Ping a Site in 20 Seconds by frankcash on Monday February 26, 2018 @08:56PM (#16470571)
Ah, I'm sorry then :( .