This topic describes how to create a custom event source of the HTTP/HTTPS Events type in the EventBridge console.

Background information

After a custom event source of the HTTP/HTTPS Event type is created, a webhook URL is generated to receive URL requests. If an event occurs in the server that is configured with the webhook URL, a message is sent through the URL to EventBridge. Then, EventBridge determines whether to convert the message to an event and push the event to the event target.

Prerequisites

Procedure

  1. Log on to the EventBridge console.
  2. In the left-side navigation pane, click Event Buses.
  3. In the top navigation bar, select a region.
  4. On the Event Buses page, click the name of the event bus that you want to manage.
  5. In the left-side navigation pane, click Event Sources.
  6. On the Event Source page, click Add Event Source.
  7. In the Add Custom Event Source panel, specify the Name and Description parameters and set the Event Provider parameter to HTTP/HTTPS Events. Set the parameters described in the following table and click OK.
    Parameter Description
    Request Type Select HTTPS, HTTP, or HTTP&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 type. Valid values:
    • Optional: No security setting is configured, and all the URL requests received are pushed as events to EventBridge.
    • CIDR Block: Enter one or more IP addresses or CIDR blocks from which requests are allowed. Only the requests from the specified IP addresses or IP addresses that belong to the specified CIDR blocks are pushed as events to EventBridge. Other URL-based requests are filtered out.
    • Security Domain Name: Enter a security domain name. Only requests that use the specified domain name are pushed as events to EventBridge. Other URL-based requests are filtered out.
    CIDR Block This parameter is required only when you set the Security Settings parameter to CIDR Block. For more information, see the description of the Security Settings parameter.
    Note You can specify up to five IP addresses or CIDR blocks.
    Security Domain Name This parameter is required only when you set the Security Settings parameter to Security Domain Name. For more information, see the description of the Security Settings parameter.
    Note You can specify up to five security domain names.

Sample event

EventBridge converts HTTP requests that meet the specified requirements to events. In the data field, the request headers are nested under the headers parameter and the body is nested under the body parameter.

{
  "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 Overview.

The following table describes the parameters in the data field.

Parameter Type Example Description
headers Map
{
    "Host":"175299981560****.eventbridge.cn-hangzhou.aliyuncs.com",
    "Accept-Encoding":"gzip, deflate, br",
    "accept":"*/*",
    "Content-Length":"538",
    "Content-Type":"application/json"
}
The headers of the HTTP request.
path String /webhook/putEvents The HTTP request path.
body String/Map
{
    "infoId":1,
    "ruleName":"Test",
    "state":"alerting",
    "message":"EventBridge test info.",
    "ruleId":"796014154722826****"
}
The body of the HTTP request. If the value of the Content-Type parameter is application/json, the body of the HTTP request is parsed as a JSON object. Otherwise, the body is parsed as a common string.
httpMethod String GET The HTTP request method.
queryString Map N/A The value of the query parameter in the HTTP request, excluding the content of the token parameter.