Serverless Webhook? Deploy Yours in 5 Minutes – or Less!

Often you may need to set up a HTTP/S endpoint (webhook) for accepting data posted from another application or service; such as GitHub webhooks. Let us see how you can set one up your next webhook in five minutes, without having to run, pay for, or maintain, a server of your own. (And hence the name "serverless webhook".)

'Callback URL': a typical webhook configuration

'Callback URL': a typical webhook configuration (source: Wikipedia)

As you may notice by the end, the major part of this five-minute adventure would be for one-time setting-up stuff; so your future serverless webhooks would just take well under two minutes!

Ingredients

Well, I do assume that you have some stuff ready; I didn't count the time for setting them up, because I already had them all 😀

  • A fairly new, desktop web browser (at least you got that, unless you're reading this on mobile; even then, you have one at home, ain't you?)

It sure sounds like quite a bit of work, but the effort is well worth it. When done, you will be fortified with almost everything you need for developing a cloud or serverless application; using any framework you like!

We'll be using Sigma, the world's one and only serverless IDE, to deploy our serverless webhook. So...

Launch Sigma!

[one minute, or two at most.]

Just go to the login page, click the signup link, and fill in a couple fields; and enter the verification code that Sigma sends you via email.

It's all outlined here, with screenshots!

nice, your account is ready!

nice, your account is ready!

Tip: You can shave off several seconds by logging in via your Facebook or Google account; just use one of the buttons at the bottom of the right-hand pane. Sigma won't steal your stuff; pinkie promise!

Once logged in, feed your cloud platform credentials to Sigma via the Cloud Credentials page. (That guide covers it as well.)

Cloud Credentials view for GCP

Cloud Credentials view for GCP

Authorize GitHub (or BitBucket).

[30 seconds tops.]

(We could do this later as well, but let's first get the time-consuming stuff done.)

Right after the above cloud credentials step, you will be in a Projects page. On its left Quick Start pane, you will see an Integrate with GitHub button.

'Projects' page with source provider integration button

'Projects' page with source provider integration button

What are you waiting for? The clock's tickin'!

Click that button, and authorize the Sigma GitHub app to access your GitHub account.

'Sigma' GitHub app authorization dialog

'Sigma' GitHub app authorization dialog

If you are that BitBucket guy, first click the BitBucket icon and then proceed to the authorization button.

Create a new project.

[20 seconds, maybe?]

On the right side of the project page, you will see a Create a New Project section.

new project creation form

new project creation form

Quickly fill in a project name, select your cloud platform from the Base Platform drop down, and click Create Project.

Serverless webhook: 2 minutes 10 seconds left!

No worries. You are already inside the editor!

Sigma has already created a serverless function (AWS Lambda or Google Cloud Function) to hold your webhook's processing logic, so the rest is a breeze.

(The default function template will return a {"message": "successfully executed"} response for the webhook request; spare a few seconds to change this to the desired response format.)

Now your path would slightly divert, based on what cloud platform you chose.

AWS

[20 seconds.]

You need an API endpoint, so drag 'n' drop an API Gateway as the trigger of your lambda. Simple: just press the mouse down on the API Gateway entry on the top of the left-hand-side Resources ; drag it all the way on to the event parameter (highlighted in red) on the first line of the code editor; and release the mouse.

dragging 'API Gateway' into the code

dragging 'API Gateway' into the code

You'll see a pop-up, asking for details of the new API. Quickly fill them in: a name, a resource path (like /webhook), the desired HTTP method (POST, usually), and a stage name (which would also appear in the final URL, right before the resource path).

API Gateway configuration pop-up, ready to accept your serverless webhook configs

API Gateway configuration pop-up, ready to accept your serverless webhook configs

When done, click Inject. The event variable will turn green, indicating that the trigger is now set.

Done!

GCP

[0 seconds. Yep. Nada. Zip.]

Man, aren't you lucky. Sigma has already added a HTTP(S) trigger to your Cloud Function, so there's really nothing to do!

GCP: Sigma already added an HTTP trigger for you!

GCP: Sigma already added an HTTP trigger for you!

Deploy it!

We are almost done with our serverless webhook - it's already ready for deployment!

It's one-click: just press the Deploy button on the toolbar!

'Deploy' button on the toolbar

'Deploy' button on the toolbar

This sets a chain of events in motion:

  • Sigma asks you for a commit message so that it can commit your project to GitHub (or BitBucket).
'Commit Changes' dialog

'Commit Changes' dialog

(As I mentioned earlier, you could have delayed the GitHub integration thing until now; but you already did it, so we can just zoom through!)

[5 seconds.]

  • There is probably no prior repository by the name of your project; so Sigma asks you whether it could create a new repo for you.

Create a new GitHub repository

[5 seconds.]

  • When the committing is complete (usually 10-15 seconds), Sigma builds your project. On AWS, this would usually take just 2-3 seconds; or around 20-30 if you are not so lucky (to be precise, if Sigma's test environment is not yet ready). About the same lag if you are on GCP - where the test environment is under construction.
build in progress

build in progress

  • After this build, Sigma brings up a Changes Summary dialog showing details of your brand new deployment.
your serverless webhook project, getting ready to deploy

your serverless webhook project, getting ready to deploy

While it is still in the "getting ready" phase, tick the Start deployment automatically when changes are ready checkbox at the bottom - so that Sigma will start deployment as soon as it is ready!

[10 seconds.]

The deployment should not take long: around 30-40 seconds on AWS, and about the same - or somewhat quicker - in GCP.

serverless webhook on GCP: deployment in progress

serverless webhook on GCP: deployment in progress

As soon as the red Stop button disappears and a green Done button comes up, stop the clock - it's done!

Hopefully all that took less than a minute 🙂

Try out your hot new serverless webhook!

If you are on AWS, the deployment dialog will give you the URL of the webhook right away:

Outputs section of the deployment dialog showing the API Gateway webhook URL

Outputs section of the deployment dialog showing the API Gateway webhook URL

So, now you can simply:

  • click the Copy button against the URL,
  • paste it into Postman (or curl, or whatever)
  • shape up and send your sample request, and
  • marvel at the serverless webhook response!

(If you already closed the deployment dialog, you can still get the URL from Deployment section of the Project Info dialog - via the info icon on the toolbar.)

Meanwhile on GCP, you can click the green lightning icon against the function signature, to view the function-specific serverless webhook URL.

GCP HTTP trigger pop-up showing the webhook URL

GCP HTTP trigger pop-up showing the webhook URL

This will usually be of the form https://{GCP region}-{GCP project name}.cloudfunctions.net/{function name prefixed with your Sigma project name}. No need to try to decipher that, though; just right-click the link and choose Copy link address.

So there!

Now you have a serverless webhook to use in any of your cloud integrations; you can combine it with the power of AWS, GCP and numerous other services - and build something great!

But, more importantly, you have:

  • signed up for - and configured - one of the leading cloud and serverless platforms;
  • completed your first full-stack serverless deployment;
  • set up the most powerful serverless IDE on the planet - right inside your web browser!

As Google puts it, "see you in the cloud" - and in Sigma - pretty soon!