You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/events.md
+26-27Lines changed: 26 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "EventBridge"
3
-
linkTitle: "EventBridge"
4
3
description: Get started with EventBridge on LocalStack
5
4
persistence: supported with limitations
6
5
tags: ["Free"]
@@ -14,12 +13,12 @@ EventBridge rules are tied to an Event Bus to manage event-driven workflows.
14
13
You can use either identity-based or resource-based policies to control access to EventBridge resources, where the former can be attached to IAM users, groups, and roles, and the latter can be attached to specific AWS resources.
15
14
16
15
LocalStack allows you to use the EventBridge APIs in your local environment to create rules that route events to a target.
17
-
The supported APIs are available on our [API coverage page]({{< ref "coverage_events" >}}), which provides information on the extent of EventBridge's integration with LocalStack.
18
-
For information on EventBridge Pipes, please refer to the [EventBridge Pipes]({{< ref "user-guide/aws/pipes" >}}) section.
16
+
The supported APIs are available on our [API coverage page](), which provides information on the extent of EventBridge's integration with LocalStack.
17
+
For information on EventBridge Pipes, please refer to the [EventBridge Pipes]() section.
19
18
20
-
{{< callout >}}
19
+
:::note
21
20
The native EventBridge provider, introduced in [LocalStack 3.5.0](https://discuss.localstack.cloud/t/localstack-release-v3-5-0/947), is now the default in 4.0. The legacy provider can still be enabled using the `PROVIDER_OVERRIDE_EVENTS=v1` configuration, but it is deprecated and will be removed in the next major release. We strongly recommend migrating to the new provider.
Run the following command to create a new Lambda function using the [`CreateFunction`](https://docs.aws.amazon.com/cli/latest/reference/lambda/create-function.html) API:
The output will consist of the `FunctionArn`, which you will need to add the Lambda function to the EventBridge target.
59
58
60
59
### Create an EventBridge Rule
61
60
62
61
Run the following command to create a new EventBridge rule using the [`PutRule`](https://docs.aws.amazon.com/cli/latest/reference/events/put-rule.html) API:
63
62
64
-
{{< command >}}
65
-
$ awslocal events put-rule \
63
+
```bash
64
+
awslocal events put-rule \
66
65
--name my-scheduled-rule \
67
66
--schedule-expression 'rate(2 minutes)'
68
-
{{< /command >}}
67
+
```
69
68
70
69
In the above command, we have specified a schedule expression of `rate(2 minutes)`, which will run the rule every two minutes.
71
70
It means that the Lambda function will be invoked every two minutes.
72
71
73
72
Next, grant the EventBridge service principal (`events.amazonaws.com`) permission to run the rule, using the [`AddPermission`](https://docs.aws.amazon.com/cli/latest/reference/events/add-permission.html) API:
@@ -96,11 +95,11 @@ Create a file named `targets.json` with the following content:
96
95
97
96
Finally, add the Lambda function as a target to the EventBridge rule using the [`PutTargets`](https://docs.aws.amazon.com/cli/latest/reference/events/put-targets.html) API:
98
97
99
-
{{< command >}}
100
-
$ awslocal events put-targets \
98
+
```bash
99
+
awslocal events put-targets \
101
100
--rule my-scheduled-rule \
102
101
--targets file://targets.json
103
-
{{< /command >}}
102
+
```
104
103
105
104
### Verify the Lambda invocation
106
105
@@ -109,27 +108,27 @@ However, wait at least 2 minutes after running the last command before checking
109
108
110
109
Run the following command to list the CloudWatch log groups:
111
110
112
-
{{< command >}}
113
-
$ awslocal logs describe-log-groups
114
-
{{< /command >}}
111
+
```bash
112
+
awslocal logs describe-log-groups
113
+
```
115
114
116
115
The output will contain the log group name, which you can use to list the log streams:
117
116
118
-
{{< command >}}
119
-
$ awslocal logs describe-log-streams \
117
+
```bash
118
+
awslocal logs describe-log-streams \
120
119
--log-group-name /aws/lambda/events-example
121
-
{{< /command >}}
120
+
```
122
121
123
122
Alternatively, you can fetch LocalStack logs to verify the Lambda invocation:
0 commit comments