API destinations as targets in Amazon EventBridge
Amazon EventBridge API destinations are HTTP endpoints that you can invoke as the target of an event bus rule, or pipe, similar to how you invoke an AWS service or resource as a target. Using API destinations, you can route events between AWS services, integrated software as a service (SaaS) applications, and your applications outside of AWS by using API calls. When you specify an API destination as a rule or pipe target, EventBridge invokes the HTTP endpoint for any event that matches the event pattern specified in the rule or pipe and then delivers the event information with the request. With EventBridge, you can use any HTTP method except CONNECT and TRACE for the request. The most common HTTP methods to use are PUT and POST. You can also use input transformers to customize the event to the parameters of a specific HTTP endpoint parameters. For more information, see Amazon EventBridge input transformation.
Note
API destinations do not support private destinations, such as interface VPC endpoints--including private HTTPS APIs in Virtual Private Clouds (VPC) using private Network and Application Load Balancer and interface VPC endpoints.
For more information, see Using Amazon EventBridge with Interface VPC endpoints.
Important
EventBridge requests to an API destination endpoint must have a maximum client execution timeout of 5 seconds. If the target endpoint takes longer than 5 seconds to respond, EventBridge times out the request. EventBridge retries timed out requests up to the maximums that are configured on your retry policy. By default the maximums are 24 hours and 185 times. After the maximum number of retries, events are sent to your dead-letter queue if you have one.Otherwise, the event is dropped.
The following video demonstrates the use of API destination:
Service-linked role for API destinations
When you create a connection for an API destination, a service-linked role named AWSServiceRoleForAmazonEventBridgeApiDestinations is added to your account. EventBridge uses the service-linked role to create and store a secret in Secrets Manager. To grant the necessary permissions to the service-linked role, EventBridge attaches the AmazonEventBridgeApiDestinationsServiceRolePolicy policy to the role. The policy limits the permissions granted to only those necessary for the role to interact with the secret for the connection. No other permissions are included, and the role can interact only with the connections in your account to manage the secret.
The following policy is the
AmazonEventBridgeApiDestinationsServiceRolePolicy
.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "secretsmanager:CreateSecret", "secretsmanager:UpdateSecret", "secretsmanager:DescribeSecret", "secretsmanager:DeleteSecret", "secretsmanager:GetSecretValue", "secretsmanager:PutSecretValue" ], "Resource": "arn:aws:secretsmanager:*:*:secret:events!connection/*" } ] }
For more information about service-linked roles, see Using service-linked roles in the IAM documentation.
Region availability
The AmazonEventBridgeApiDestinationsServiceRolePolicy
service-linked role
is supported in the following AWS regions:
-
US East (N. Virginia)
-
US East (Ohio)
-
US West (N. California)
-
US West (Oregon)
-
Africa (Cape Town)
-
Asia Pacific (Hong Kong)
-
Asia Pacific (Mumbai)
-
Asia Pacific (Osaka)
-
Asia Pacific (Seoul)
-
Asia Pacific (Singapore)
-
Asia Pacific (Sydney)
-
Asia Pacific (Tokyo)
-
Canada (Central)
-
Europe (Frankfurt)
-
Europe (Ireland)
-
Europe (London)
-
Europe (Milan)
-
Europe (Paris)
-
Europe (Stockholm)
-
South America (São Paulo)
-
China (Ningxia)
-
China (Beijing)
Headers in requests to API destinations
The following section details how EventBridge handles HTTP headers in requests to API destinations.
Headers included in requests to API destinations
In addition to the authorization headers defined for the connection used for an API destination, EventBridge includes the following headers in each request.
Header key | Header value |
---|---|
User-Agent |
Amazon/EventBridge/ApiDestinations |
Content-Type |
If no custom Content-Type value is specified, EventBridge includes the following default value as Content-Type: application/json; charset=utf-8 |
Range |
bytes=0-1048575 |
Accept-Encoding |
gzip,deflate |
Connection |
close |
Content-Length |
An entity header that indicates the size of the entity-body, in bytes, sent to the recipient. |
Host |
A request header that specifies the host and port number of the server where the request is being sent. |
Headers that cannot be overridden in requests to API destinations
EventBridge does not allow you to override the following headers:
-
User-Agent
-
Range
Headers EventBridge removes from requests to API destinations
EventBridge removes the following headers for all API destination requests:
-
A-IM
-
Accept-Charset
-
Accept-Datetime
-
Accept-Encoding
-
Cache-Control
-
Connection
-
Content-Encoding
-
Content-Length
-
Content-MD5
-
Date
-
Expect
-
Forwarded
-
From
-
Host
-
HTTP2-Settings
-
If-Match
-
If-Modified-Since
-
If-None-Match
-
If-Range
-
If-Unmodified-Since
-
Max-Forwards
-
Origin
-
Pragma
-
Proxy-Authorization
-
Range
-
Referer
-
TE
-
Trailer
-
Transfer-Encoding
-
User-Agent
-
Upgrade
-
Via
-
Warning
API destination error codes
When EventBridge tries to deliver an event to an API destination and an error occurs, EventBridge does the following:
-
Events associated with error codes 409, 429, and 5xx are retried.
-
Events associated with error codes 1xx, 2xx, 3xx, and 4xx (excluding 429) aren't retried.
EventBridge API destinations read the standard HTTP response header Retry-After
to find out how long to wait before making a follow-up request. EventBridge chooses the more
conservative value between the defined retry policy and the Retry-After
header. If Retry-After
value is negative, EventBridge stops retrying delivery for
that event.
How invocation rate affects event delivery
If you set the invocation rate per second to a value much lower than the number of invocations generated, events may not be delivered within the 24 hour retry time for events. For example, if you set the invocation rate to 10 invocations per second, but thousands of events per second are generated, you will quickly have a backlog of events to deliver that exceeds 24 hours. To ensure that no events are lost, set up a dead-letter queue to send events with failed invocations to so you can process the events at a later time. For more information, see Using dead-letter queues to process undelivered events in EventBridge.