|
| 1 | +# EventBridge Scheduler code examples for the SDK for Python |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Shows how to use the AWS SDK for Python (Boto3) to work with Amazon EventBridge Scheduler. |
| 6 | + |
| 7 | +<!--custom.overview.start--> |
| 8 | +<!--custom.overview.end--> |
| 9 | + |
| 10 | +_EventBridge Scheduler allows you to create, run, and manage tasks on a schedule from one central, managed service._ |
| 11 | + |
| 12 | +## ⚠ Important |
| 13 | + |
| 14 | +* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/). |
| 15 | +* Running the tests might result in charges to your AWS account. |
| 16 | +* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). |
| 17 | +* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). |
| 18 | + |
| 19 | +<!--custom.important.start--> |
| 20 | +<!--custom.important.end--> |
| 21 | + |
| 22 | +## Code examples |
| 23 | + |
| 24 | +### Prerequisites |
| 25 | + |
| 26 | +For prerequisites, see the [README](../../README.md#Prerequisites) in the `python` folder. |
| 27 | + |
| 28 | +Install the packages required by these examples by running the following in a virtual environment: |
| 29 | + |
| 30 | +``` |
| 31 | +python -m pip install -r requirements.txt |
| 32 | +``` |
| 33 | + |
| 34 | +<!--custom.prerequisites.start--> |
| 35 | +<!--custom.prerequisites.end--> |
| 36 | + |
| 37 | +### Get started |
| 38 | + |
| 39 | +- [Hello EventBridge Scheduler](hello/hello_scheduler.py#L4) (`ListSchedules`) |
| 40 | + |
| 41 | + |
| 42 | +### Single actions |
| 43 | + |
| 44 | +Code excerpts that show you how to call individual service functions. |
| 45 | + |
| 46 | +- [CreateSchedule](scheduler_wrapper.py#L38) |
| 47 | +- [CreateScheduleGroup](scheduler_wrapper.py#L131) |
| 48 | +- [DeleteSchedule](scheduler_wrapper.py#L104) |
| 49 | +- [DeleteScheduleGroup](scheduler_wrapper.py#L160) |
| 50 | + |
| 51 | +### Scenarios |
| 52 | + |
| 53 | +Code examples that show you how to accomplish a specific task by calling multiple |
| 54 | +functions within the same service. |
| 55 | + |
| 56 | +- [Scheduled Events workflow](scenario/scheduler_scenario.py) |
| 57 | + |
| 58 | + |
| 59 | +<!--custom.examples.start--> |
| 60 | +<!--custom.examples.end--> |
| 61 | + |
| 62 | +## Run the examples |
| 63 | + |
| 64 | +### Instructions |
| 65 | + |
| 66 | + |
| 67 | +<!--custom.instructions.start--> |
| 68 | +<!--custom.instructions.end--> |
| 69 | + |
| 70 | +#### Hello EventBridge Scheduler |
| 71 | + |
| 72 | +This example shows you how to get started using EventBridge Scheduler. |
| 73 | + |
| 74 | +``` |
| 75 | +python hello/hello_scheduler.py |
| 76 | +``` |
| 77 | + |
| 78 | + |
| 79 | +#### Scheduled Events workflow |
| 80 | + |
| 81 | +This example shows you how to do the following: |
| 82 | + |
| 83 | +- Deploy a CloudFormation stack with required resources. |
| 84 | +- Create a EventBridge Scheduler schedule group. |
| 85 | +- Create a one-time EventBridge Scheduler schedule with a flexible time window. |
| 86 | +- Create a recurring EventBridge Scheduler schedule with a specified rate. |
| 87 | +- Delete EventBridge Scheduler the schedule and schedule group. |
| 88 | +- Clean up resources and delete the stack. |
| 89 | + |
| 90 | +<!--custom.scenario_prereqs.scheduler_ScheduledEventsWorkflow.start--> |
| 91 | +<!--custom.scenario_prereqs.scheduler_ScheduledEventsWorkflow.end--> |
| 92 | + |
| 93 | +Start the example by running the following at a command prompt: |
| 94 | + |
| 95 | +``` |
| 96 | +python scenario/scheduler_scenario.py |
| 97 | +``` |
| 98 | + |
| 99 | + |
| 100 | +<!--custom.scenarios.scheduler_ScheduledEventsWorkflow.start--> |
| 101 | +<!--custom.scenarios.scheduler_ScheduledEventsWorkflow.end--> |
| 102 | + |
| 103 | +### Tests |
| 104 | + |
| 105 | +⚠ Running tests might result in charges to your AWS account. |
| 106 | + |
| 107 | + |
| 108 | +To find instructions for running these tests, see the [README](../../README.md#Tests) |
| 109 | +in the `python` folder. |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +<!--custom.tests.start--> |
| 114 | +<!--custom.tests.end--> |
| 115 | + |
| 116 | +## Additional resources |
| 117 | + |
| 118 | +- [EventBridge Scheduler User Guide](https://docs.aws.amazon.com/scheduler/latest/userguide/intro.html) |
| 119 | +- [EventBridge Scheduler API Reference](https://docs.aws.amazon.com/scheduler/latest/apireference/Welcome.html) |
| 120 | +- [SDK for Python EventBridge Scheduler reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/scheduler.html) |
| 121 | + |
| 122 | +<!--custom.resources.start--> |
| 123 | +<!--custom.resources.end--> |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 128 | + |
| 129 | +SPDX-License-Identifier: Apache-2.0 |
0 commit comments