AWS eventbridge documentation change
Summary
Rewrote tutorial to deprecate EventBridge scheduled rules and recommend EventBridge Scheduler instead. Removed step-by-step instructions for legacy scheduled rules and added guidance for new Scheduler service.
Security assessment
The changes focus on feature deprecation and service migration without mentioning security vulnerabilities, weaknesses, or incidents. The update promotes EventBridge Scheduler for its functional benefits (scalability, target flexibility, time windows) but doesn't reference security improvements or address specific security issues.
Diff
diff --git a/eventbridge/latest/userguide/eb-run-lambda-schedule.md b/eventbridge/latest/userguide/eb-run-lambda-schedule.md index c1cd2b441..a12bd7e2f 100644 --- a//eventbridge/latest/userguide/eb-run-lambda-schedule.md +++ b//eventbridge/latest/userguide/eb-run-lambda-schedule.md @@ -5 +5 @@ -Step 1: Create a Lambda functionStep 2: Create a RuleStep 3: Verify the ruleStep 4: Confirm successStep 5: Clean up your resources +# Tutorial: Schedule a AWS Lambda function @@ -7 +7 @@ Step 1: Create a Lambda functionStep 2: Create a RuleStep 3: Verify the ruleStep -# Tutorial: Create an EventBridge scheduled rule for AWS Lambda functions +###### Note @@ -9 +9 @@ Step 1: Create a Lambda functionStep 2: Create a RuleStep 3: Verify the ruleStep -You can set up a [rule](./eb-rules.html) to run an [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) function on a schedule. This tutorial shows how to use the AWS Management Console or the AWS CLI to create the rule. If you want to use the AWS CLI but haven't installed it, see the [Installing, updating, and uninstalling the AWS CLI version 2](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html). +Scheduled rules are a legacy feature of EventBridge. @@ -11 +11 @@ You can set up a [rule](./eb-rules.html) to run an [AWS Lambda](https://docs.aws -For schedules, EventBridge doesn't provide second-level precision in [schedule expressions](./eb-create-rule-schedule.html). The finest resolution using a cron expression is one minute. Due to the distributed nature of EventBridge and the target services, there can be a delay of several seconds between the time the scheduled rule is triggered and the time the target service runs the target resource. +EventBridge offers a more flexible and powerful way to create, run, and manage scheduled tasks centrally, at scale: EventBridge Scheduler. With EventBridge Scheduler, you can create schedules using cron and rate expressions for recurring patterns, or configure one-time invocations. You can set up flexible time windows for delivery, define retry limits, and set the maximum retention time for failed API invocations. @@ -13 +13 @@ For schedules, EventBridge doesn't provide second-level precision in [schedule e -###### Steps: +Scheduler is highly customizable, and offers improved scalability over scheduled rules, with a wider set of target API operations and AWS services. We recommend that you use Scheduler to invoke targets on a schedule. @@ -15 +15 @@ For schedules, EventBridge doesn't provide second-level precision in [schedule e - * Step 1: Create a Lambda function +For more information, see [Create a schedule](./using-eventbridge-scheduler.html#using-eventbridge-scheduler-create) or the _[EventBridge Scheduler User Guide](https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html)_. @@ -17,183 +17 @@ For schedules, EventBridge doesn't provide second-level precision in [schedule e - * Step 2: Create a Rule - - * Step 3: Verify the rule - - * Step 4: Confirm success - - * Step 5: Clean up your resources - - - - -## Step 1: Create a Lambda function - -Create a Lambda function to log the scheduled events. - -###### To create a Lambda function - - 1. Open the AWS Lambda console at [https://console.aws.amazon.com/lambda/](https://console.aws.amazon.com/lambda/). - - 2. Choose **Create function**. - - 3. Choose **Author from scratch**. - - 4. Enter a name and description for the Lambda function. For example, name the function `LogScheduledEvent`. - - 5. Leave the rest of the options as the defaults and choose **Create function**. - - 6. On the **Code** tab of the function page, double-click **index.js**. - - 7. Replace the existing code with the following code. - - 'use strict'; - - exports.handler = (event, context, callback) => { - console.log('LogScheduledEvent'); - console.log('Received event:', JSON.stringify(event, null, 2)); - callback(null, 'Finished'); - }; - - 8. Choose **Deploy**. - - - - -## Step 2: Create a Rule - -Create a rule to run the Lambda function you created in step 1 on a schedule. - -You can use either the console or the AWS CLI to create the rule. To use the AWS CLI, you first grant the rule permission to invoke your Lambda function. Then you can create the rule and add the Lambda function as a target. - -###### To create a rule (console) - - 1. Open the Amazon EventBridge console at [https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/). - - 2. In the navigation pane, choose **Rules**. - - 3. Choose **Create rule**. - - 4. Enter a name and description for the rule. - -A rule can't have the same name as another rule in the same Region and on the same event bus. - - 5. For **Event bus** , choose the event bus that you want to associate with this rule. If you want this rule to match events that come from your account, select **AWS default event bus**. When an AWS service in your account emits an event, it always goes to your account’s default event bus. - - 6. For **Rule type** , choose **Schedule**. - - 7. Choose **Next**. - - 8. For **Schedule pattern** , choose **A schedule that runs at a regular rate, such as every 10 minutes.** and enter `5` and choose **Minutes** from the drop-down list. - - 9. Choose **Next**. - - 10. For **Target types** , choose **AWS service**. - - 11. For **Select a target** , choose **Lambda function** from the drop-down list. - - 12. For **Function** , select the Lambda function that you created in the **Step 1: Create a Lambda function** section. In this example, select `LogScheduledEvent`. - - 13. Choose **Next**. - - 14. Choose **Next**. - - 15. Review the details of the rule and choose **Create rule**. - - - - -###### To create a rule (AWS CLI) - - 1. To create a rule that runs on a schedule, use the `put-rule` command. - - aws events put-rule \ - --name my-scheduled-rule \ - --schedule-expression 'rate(5 minutes)' - -When this rule runs, it creates an event and then sends it to the targets. The following is an example event. - - { - "version": "0", - "id": "53dc4d37-cffa-4f76-80c9-8b7d4a4d2eaa", - "detail-type": "Scheduled Event", - "source": "aws.events", - "account": "123456789012", - "time": "2015-10-08T16:53:06Z", - "region": "us-east-1", - "resources": [ - "arn:aws:events:us-east-1:123456789012:rule/my-scheduled-rule" - ], - "detail": {} - } - - 2. To grant the EventBridge service principal (`events.amazonaws.com`) permission to run the rule, use the `add-permission` command. - - aws lambda add-permission \ - --function-name LogScheduledEvent \ - --statement-id my-scheduled-event \ - --action 'lambda:InvokeFunction' \ - --principal events.amazonaws.com \ - --source-arn arn:aws:events:us-east-1:123456789012:rule/my-scheduled-rule - - 3. Create the file `targets.json` with the following contents. - - [ - { - "Id": "1", - "Arn": "arn:aws:lambda:us-east-1:123456789012:function:LogScheduledEvent" - } - ] - - 4. To add the Lambda function that you created in step 1 to the rule, use the `put-targets`command . - - aws events put-targets --rule my-scheduled-rule --targets file://targets.json - - - - -## Step 3: Verify the rule - -Wait at least five minutes after completing step 2, and then you can verify that your Lambda function was invoked. - -###### View the output from your Lambda function - - 1. Open the CloudWatch console at [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/). - - 2. In the navigation pane, choose **Logs**. - - 3. Select the name of the log group for your Lambda function (`/aws/lambda/`function-name``). - - 4. Select the name of the log stream to view the data provided by the function for the instance that you launched. - - - - -## Step 4: Confirm success - -If you see the Lambda event in the CloudWatch logs, you've successfully completed this tutorial. If the event isn't in your CloudWatch logs, start troubleshooting by verifying the rule was created successfully and, if the rule looks correct, verify the code of your Lambda function is correct. - -## Step 5: Clean up your resources - -You can now delete the resources that you created for this tutorial, unless you want to retain them. By deleting AWS resources that you are no longer using, you prevent unnecessary charges to your AWS account. - -###### To delete the EventBridge rule(s) - - 1. Open the [Rules page](https://console.aws.amazon.com/events/home#/rules) of the EventBridge console. - - 2. Select the rule(s) that you created. - - 3. Choose **Delete**. - - 4. Choose **Delete**. - - - - -###### To delete the Lambda function(s) - - 1. Open the [Functions page](https://console.aws.amazon.com/lambda/home#/functions) of the Lambda console.