Skip to content

Commit fe1d0d4

Browse files
committed
Update Blog “getting-started-with-the-hpe-greenlake-cloud-eventing-framework”
1 parent 60d0070 commit fe1d0d4

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

content/blog/getting-started-with-the-hpe-greenlake-cloud-eventing-framework.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ul li{
1313
font-size:27px;
1414
}
1515
</style>
16+
1617
<style>
1718
ol li{
1819
font-size:25px;
@@ -31,9 +32,7 @@ The following diagram illustrates the mechanism by which this works:
3132

3233
![HPE GreenLake eventing framework](/img/presentation2-auto-saved-.jpg "HPE GreenLake eventing framework")
3334

34-
## \
35-
36-
How do you write webhook handlers?
35+
## How do you write webhook handlers?
3736

3837
There are many ways you can write a webhook handler. You could use traditional languages such as Node.js (using Express.js), Python (using Flask) or Ruby (using Sinatra). Also very popular is the use of serverless functions such as AWS Lambda or Google Cloud Functions. You could also use low-code/no-code platforms such as Zapier, Make or Automate.io. Another option is to use an existing platform that supports webhooks such as ServiceNow or HPE OpsRamp.
3938

@@ -50,9 +49,7 @@ Additional requirements for writing a webhook handler for HPE GreenLake include:
5049
* The endpoint needs to use HTTPS
5150
* The handler needs to respond to the initial challenge through the use of a shared secret key
5251

53-
## \
54-
55-
Taking the challenge
52+
## Taking the challenge
5653

5754
From the picture above, you can see that the webhook handler is a piece of code that runs outside of the HPE GreenLake cloud, possibly posing a security risk. In order to avoid calling a rogue code, HPE GreenLake will establish a trust relationship with the webhook handler by issuing a challenge request and expecting a very specific response. The challenge is an HTTP POST request that is sent to the webhook handler (via its URL) with a payload containing a **challengeRequest** as shown below:
5855

@@ -71,14 +68,11 @@ From the picture above, you can see that the webhook handler is a piece of code
7168
}
7269
```
7370

74-
\
7571
The mission of the challenge handler is to provide the correct answer to the challenge in a timely fashion and with an HTTP response in the following form:
7672

77-
* Status code = 200
73+
* Status code: 200
7874
* JSON body: { “verification” : “<CHALLENGE-RESPONSE>”}
79-
* Header:
80-
81-
*   content-type: application/json
75+
* Header: content-type: application/json
8276

8377
Where **<CHALLENGE-RESPONSE>** is the computed [SHA-256](https://en.wikipedia.org/wiki/SHA-2) [HMAC](https://en.wikipedia.org/wiki/HMAC) (Hash-based Message Authentication Code) of the **challengeRequest** provided in the input payload.
8478

@@ -129,11 +123,9 @@ Now that you have a clear understanding of what has to be done within a webhook
129123

130124
I decided to use Make (previously known as Integromat , which was a great name as it was a contraction of Integration-Automat and that is exactly what it is) to demonstrate this because:
131125

132-
\-          it doesn’t require any specific programming language knowledge
133-
134-
\-          it provides a FQDN of the webhook over HTTPS
135-
136-
\-          it’s free for simple prototyping usage
126+
* it doesn’t require any specific programming language knowledge
127+
* it provides a FQDN of the webhook over HTTPS
128+
* it’s free for simple prototyping usage
137129

138130
It turned out to be a very elegant and fast way to get the work done.
139131

@@ -149,9 +141,9 @@ Give it a name and leave the rest of the settings as their defaults.
149141

150142
![Use URL of Webhook](/img/create-webhook-2.jpg "Use URL of Webhook")
151143

152-
You can already copy address to clipboard to get the URL of your webhook. **Save it** for later.
144+
You can already **Copy address to clipboard** to get the URL of your webhook. Save it for later.
153145

154-
Select the **Add** button, then click on **Show Advanced Option** to add a data structure using the payload example from the Take the challenge section above. Click ge**nerate,** paste the JSON and save it as **challenge**.
146+
Select the **Add** button, then click on **Show Advanced Option** to add a data structure using the payload example from the Take the challenge section above. Click **generate,** paste the JSON and save it as **challenge**.
155147

156148
Make sure the **challenge** data structure is selected in the advanced settings of the Webhooks module before continuing.
157149

@@ -166,20 +158,19 @@ Configure the Set variable module with:
166158
* Variable name: **hmac** 
167159
* Variable value: **sha256( challengeRequest ; ; <SecretKey> )**
168160

169-
Note: *you can drag the **challengeRequest** property from the **Webhooks** module, and drop it as your first parameter. **<SecretKey>** is a placeholder which you will  replace later, once we know the the real shared secret key.*
161+
Note: you can drag the **challengeRequest** property from the **Webhooks** module, and drop it as your first parameter. **<SecretKey>** is a placeholder which you will  replace later, once we know the the real shared secret key.
170162

171163
![drag and drop properties](/img/drag-drop-properties.jpg "drag and drop properties")
172164

173-
\
174165
The final step is to prepare the response of the webhook. For this, you need to add another module after the **Set variable** module, called **Webhook response**.
175166

176167
![Add webhook response](/img/add-webhook-response.jpg "Add webhook response")
177168

178-
Set the status to **200** and the body to **{verification” : “”}**,then drag/drop the **hmac** property from the **Set variable** step in between the double quotes.
169+
Set the status to **200** and the body to **{"verification":""}**, then drag/drop the **hmac** property from the **Set variable** step in between the double quotes.
179170

180171
![Set webhook response](/img/setwebhook-response.jpg "Set webhook response")
181172

182-
In the advanced settings, add a custom header for content-type: application/json
173+
In the advanced settings, add a custom header for **content-type: application/json**
183174

184175
Your overall workflow basically looks like this:
185176

@@ -244,7 +235,6 @@ Create a second Postman **POST** request using the same webhook URL but this tim
244235

245236
![Post event in Postman](/img/post-event-in-postman.jpg "Post event in Postman")
246237

247-
\
248238
Click **Send** in Postman, and check in Make (in the scenario’s history) that the second route was taken, as shown below.
249239

250240
![Second route was taken](/img/second-route-taken.jpg "Second route was taken")
@@ -284,7 +274,7 @@ From the web console, you can now **subscribe to events** available from the HPE
284274

285275
Select your webhook from the list and select Subscribe to event. Select the source Service manager (there is only HPE GreenLake Platform for now), then cut/paste the event name from the [event catalog](https://developer.greenlake.hpe.com/docs/greenlake/services/#event-catalog). For example:
286276

287-
```
277+
```markdown
288278
com.hpe.greenlake.audit-log.v1.logs.created
289279
com.hpe.greenlake.subscriptions.v1.expiring-subscriptions
290280
```

0 commit comments

Comments
 (0)