Profile PictureOpenFaaS Store

Free 40 USD discount To Get A Grasp on Functions

Hi, it's Alex here. I hope you're enjoying the hot summer.

You're hearing from me because you bought something from the OpenFaaS store or you maybe registered to hear from me on one of my blogs.

I want to share my 5 ways to automate and extend an existing website or service using functions. I've also got a generous offer for you, to make it all a bit more interesting. The goal of the eBook is to give you a grasp of what functions can do - to show you how to deploy them even without Kubernetes, secure and monitor them too.

I'm including links for each approach to give you a starting point.

I've got a 40 USD discount on my eBook Serverless For Everyone Else, valid until 28th August. Just buy the DevOps Pro tier, and you'll get upgraded via email. All the examples are written in Node.js, and can be easily translated to other languages like Python or Go.

I had to write some code to make this offer happen, but why?

Gumroad is an excellent platform for selling eBooks and licensed software, they handle things like sales tax and VAT, and have a built-in way to email your audience with updates and offers.

One thing they lack, is the ability to discount just a single tier of your products, without applying that same discount to every other tier. So if I offered you 40USD off, and you bought the entry level eBook at 35 USD, it'd be completely free.

So I set about writing some code to extend Gumroad.

There are 5 ways to extend a product or service with functions:

1) Use their SDK with your programming language of choice - polling periodically, or reacting to events - Keep your functions running to schedule with the cron-connector

2) Subscribe to webhooks - the most efficient choice in my mind, making updates via HTTP API or SDK as required. Tracking Stripe Payments with Slack and faasd

3) Scrape HTML directly from their webpages - very fast, quite brittle, and doesn't work well if they render client-side or need authentication

4) Load up a headless web-browser like Puppeteer or Chrome and Selenium - this is a powerful approach, and requires extra compute, it's also the slowest option, but can work when nothing else does. Web scraping that just works with OpenFaaS with Puppeteer

5) Use their RSS feed to gather data - as per this example: Finding Raspberry Pis with Raspberry Pis

How my function works

First of all, I set up Gumroad to send webhooks to my Raspberry Pi, running faasd. It's exposed over an inlets tunnel with a HTTPS domain so there's no need to maintain dynamic DNS or to set up any brittle port-forwarding. I also don't have to pay for a server to host faasd, so it's kind of "serverless"? Then I wrote a function to parse and verify the webhook. It loads up the product data, to see if we received a purchase for the DevOps Pro tier.

Next, an email function is used to render a template into HTML and plaintext, which is sent to your inbox using AWS SES.

That's it, you're now upgraded.

Perhaps in the future, there may be a way to simply access the Gumroad API to change your tier programmatically?

Functions are easy to write, quick to deploy, and you can use them to extend other systems when they don't quite meet your needs.

Since 2016, we've added tutorials and blog posts for Go, Java, Node.js, Python, Ruby .NET / C# and more. You can find some of the examples in the openfaas/faas repo: https://github.com/openfaas/faas/tree/master/sample-functions

Enjoy the rest of your week! You can take up the offer, if you fancy it over at https://store.openfaas.com/l/serverless-for-everyone-else

Alex

0 comments

Current user avatar

Holiday reading, my first code in Go and a new batch of keycaps

👑🇬🇧 Platinum Jubilee Offer and my KubeCon Trip Report

KubeCon, here we come!

Tomorrow! The Business of Open Source

A couple of freebies and 28% off for Easter

See all posts from OpenFaaS Store

Powered by