Create a custom event source with an HTTP/HTTPS Events in the EventBridge console to receive HTTP requests and route them as events.
Background
After you create a custom event source with an HTTP/HTTPS Events, EventBridge generates a webhook URL that serves as an endpoint for receiving HTTP requests. When an event occurs on a server configured with this webhook, the server sends a message to EventBridge through the URL. EventBridge then determines whether to convert the message into an event and push it to an event target.
Prerequisites
Procedure
- Log on to the EventBridge console.
- In the left-side navigation pane, click Event Buses.
- In the top navigation bar, select a region.
On the Event Buses page, click the name of the event bus that you want to manage.
In the left-side navigation pane, click Event Sources.
- On the Event Source page, click Add Event Source.
- In the Add Custom Event Source panel, enter a Name and Description, select HTTP/HTTPS Events for Event Provider, configure the following parameters, and then click OK.
Parameter Description Request Type Select HTTPS, HTTP, or HTTP and HTTPS. Request Method Select one or more supported HTTP request methods. Valid values: - GET
- POST
- PUT
- DELETE
- HEAD
- PATCH
Security Settings Select a security setting. Valid values: - None: No security configuration is required. All received requests are converted into events and pushed to EventBridge.
- CIDR Block: Enter a valid IP address or CIDR block. Only requests from the specified IP addresses or CIDR blocks are converted into events and pushed to EventBridge. EventBridge filters out all other requests.
- Security Domain Name: Enter a secure domain name. Only requests from the specified domain names are converted into events and pushed to EventBridge. EventBridge filters out all other requests.
CIDR Block This parameter is required only when you set Security Settings to CIDR Block. For more information, see the Security Settings description. Note You can add up to five IP addresses or CIDR blocks.Security Domain Name This parameter is required only when you set Security Settings to Security Domain Name. For more information, see the Security Settings description. Note You can add up to five security domain names.
Event example
EventBridge converts compliant HTTP requests into events, mapping the request headers and body to the headers and body fields in the event's data field.
{
"datacontenttype": "application/json",
"aliyunaccountid": "175299981560****",
"data": {
"headers": {
"Host": "175299981560****.eventbridge.cn-hangzhou.aliyuncs.com",
"Accept-Encoding": "gzip, deflate, br",
"accept": "*/*",
"Content-Length": "538",
"Content-Type": "application/json"
},
"path": "/webhook/putEvents",
"body": {
"infoId": 1,
"ruleName": "Test",
"state": "alerting",
"message": "EventBridge test info.",
"ruleId": "796014154722826****"
},
"httpMethod": "GET",
"queryString": {}
},
"subject": "acs:eventbridge:cn-hangzhou:175299981560****:eventbus/EventBridgeDemoBus/eventsource/my.httpSource",
"aliyunoriginalaccountid": "175299981560****",
"source": "my.httpSource",
"type": "eventbridge:Events:HTTPEvent",
"aliyunpublishtime": "2022-03-03T03:33:14.097Z",
"specversion": "1.0",
"aliyuneventbusname": "EventBridgeDemoBus",
"id": "ac0d574c-d862-4662-a87b-784e3d77****",
"time": "2022-03-03T11:33:14.093+08:00",
"aliyunregionid": "cn-hangzhou",
"aliyunpublishaddr": "42.120.XX.XX"
}
For more information about the parameters defined in the CloudEvents specification, see Event overview.
The data field contains the following parameters.
| Parameter | Type | Example | Description |
headers |
Map | |
The HTTP request headers. |
path |
String | /webhook/putEvents | The HTTP request path. |
body |
String/Map | |
The HTTP request body. If the Content-Type field of the HTTP request is set to application/json, EventBridge parses the request body as a JSON object. Otherwise, it is parsed as a string. |
httpMethod |
String | GET | The HTTP request method. |
queryString |
Map | None | The request's query parameters, excluding the token parameter. |