翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
でスケジューラを使用して EventBridge時間ベースのイベントを管理する AWS SAM
Amazon EventBridge Scheduler とは
Amazon EventBridge Scheduler は、すべてのサービスで何千万ものイベントやタスクを作成、開始、管理できるスケジューリング AWS サービスです。このサービスは、時間関連のイベントに特に役立ちます。これを使用して、イベントと定期的な時間ベースの呼び出しをスケジュールできます。また、1 回限りのイベントと、開始時刻と終了時刻のレート式と同期式もサポートしています。
Amazon Scheduler の詳細については、 EventBridge スケジューラユーザーガイドの「Amazon EventBridge Scheduler とは」を参照してください。 EventBridge
EventBridge でのスケジューラのサポート AWS SAM
AWS Serverless Application Model (AWS SAM) テンプレート仕様は、 AWS Lambda および のス EventBridge ケジューラでイベントをスケジュールするために使用できるシンプルで短い構文を提供します AWS Step Functions。
でのス EventBridge ケジューライベントの作成 AWS SAM
ScheduleV2
プロパティを AWS SAM テンプレートのイベントタイプとして設定し、ス EventBridge ケジューライベントを定義します。このプロパティは、AWS::Serverless::Function
および AWS::Serverless::StateMachine
リソースタイプをサポートします。
MyFunction: Type: AWS::Serverless::Function Properties: Events: CWSchedule: Type: ScheduleV2 Properties: ScheduleExpression: 'rate(1 minute)' Name: TestScheduleV2Function Description: Test schedule event MyStateMachine: Type: AWS::Serverless::StateMachine Properties: Events: CWSchedule: Type: ScheduleV2 Properties: ScheduleExpression: 'rate(1 minute)' Name: TestScheduleV2StateMachine Description: Test schedule event
EventBridge スケジューライベントスケジューリングは、未処理のイベントのデッドレターキュー (DLQ) もサポートしています。デッドレターキューの詳細については、スケジューラEventBridge ユーザーガイドの「ス EventBridge ケジューラのデッドレターキューの設定」を参照してください。
DLQ ARN を指定すると、 はスケジューラスケジュールのアクセス許可 AWS SAM を設定して DLQ にメッセージを送信します。DLQ ARN が指定されていない場合、 は DLQ AWS SAM リソースを作成します。
例
でス EventBridge ケジューライベントを定義する基本的な例 AWS SAM
Transform: AWS::Serverless-2016-10-31 Resources: MyLambdaFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: python3.8 InlineCode: | def handler(event, context): print(event) return {'body': 'Hello World!', 'statusCode': 200} MemorySize: 128 Events: Schedule: Type: ScheduleV2 Properties: ScheduleExpression: rate(1 minute) Input: '{"hello": "simple"}' MySFNFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: python3.8 InlineCode: | def handler(event, context): print(event) return {'body': 'Hello World!', 'statusCode': 200} MemorySize: 128 StateMachine: Type: AWS::Serverless::StateMachine Properties: Type: STANDARD Definition: StartAt: MyLambdaState States: MyLambdaState: Type: Task Resource: !GetAtt MySFNFunction.Arn End: true Policies: - LambdaInvokePolicy: FunctionName: !Ref MySFNFunction Events: Events: Schedule: Type: ScheduleV2 Properties: ScheduleExpression: rate(1 minute) Input: '{"hello": "simple"}'
詳細はこちら
スScheduleV2
EventBridge ケジューラプロパティの定義の詳細については、以下を参照してください。
-
AWS::Serverless::Function
用の ScheduleV2。 -
AWS::Serverless::StateMachine
用の ScheduleV2。