

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# EventBridge スケジューラでのテンプレート化されたターゲットの使用
<a name="managing-targets-templated"></a>

 *テンプレート化されたターゲット*は、Amazon SQS、Step Functions などのコア AWS サービスのグループ全体で共通の API オペレーションのセットです。例えば、関数 ARN を指定することで Lambda の [https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke) オペレーションをターゲットにしたり、キュー ARN を使用して Amazon SQS の [https://docs.aws.amazon.com/](https://docs.aws.amazon.com/) オペレーションをターゲットにしたりできます。テンプレート化されたターゲットを設定するには、ターゲットの API オペレーションを実行するためのアクセス権限をスケジュールの実行ロールに付与する必要もあります。

 AWS CLI または EventBridge スケジューラ SDKs のいずれかを使用してプログラムでテンプレート化されたターゲットを設定するには、実行ロールの ARN、ターゲットリソースの ARN、EventBridge スケジューラがターゲットに配信するオプションの入力、および一部のテンプレート化されたターゲットでは、そのターゲットに追加の設定オプションを含む一意のパラメータセットを指定する必要があります。テンプレート化されたターゲットリソースの ARN を指定すると、EventBridge スケジューラは、そのサービスでサポートされている API オペレーションを呼び出したいと自動的に想定します。EventBridge スケジューラでサービスの別の API オペレーションをターゲットにする場合は、ターゲットを[ユニバーサルターゲット](managing-targets-universal.md)として設定する必要があります。

 以下は、EventBridge スケジューラがサポートしているすべてのテンプレート化されたターゲット、および該当する場合は各ターゲット固有の関連パラメータの完全なリストです。各パラメータセットのリンクを選択すると、*EventBridge スケジューラ API リファレンス*の必須フィールドとオプションフィールドが表示されます。
+ **CodeBuild** – [https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuild.html](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuild.html)
+ **CodePipeline** – [https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StartPipelineExecution.html](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_StartPipelineExecution.html)
+ **Amazon ECS** – [https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html)
  + パラメータ: [https://docs.aws.amazon.com/scheduler/latest/APIReference/API_EcsParameters.html](https://docs.aws.amazon.com/scheduler/latest/APIReference/API_EcsParameters.html)
+ **EventBridge** – [https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html)
  + パラメータ: [https://docs.aws.amazon.com/scheduler/latest/APIReference/API_EventBridgeParameters.html](https://docs.aws.amazon.com/scheduler/latest/APIReference/API_EventBridgeParameters.html)
**重要**  
EventBridge スケジューラは、EventBridge をテンプレート化されたターゲット`PutEvents`として使用する場合、クロスリージョン配信をサポートしていません。このターゲットを使用して、イベントバスがスケジュール AWS リージョン と同じ にある AWS アカウント 場合にのみ、別の のイベントバスにイベントを送信できます。別のリージョンのイベントバスにイベントを送信するには、ターゲットイベントバスがあるリージョンにスケジュールを作成します。
+ **Amazon Inspector** – [https://docs.aws.amazon.com/inspector/v1/APIReference/API_StartAssessmentRun.html](https://docs.aws.amazon.com/inspector/v1/APIReference/API_StartAssessmentRun.html)
+ **Kinesis** – [https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html)
  + パラメータ: [https://docs.aws.amazon.com/scheduler/latest/APIReference/API_KinesisParameters.html](https://docs.aws.amazon.com/scheduler/latest/APIReference/API_KinesisParameters.html)
+ **Firehose** – [https://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecord.html](https://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecord.html)
+ **Lambda** – [https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html)
+ **SageMaker AI** – [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_StartPipelineExecution.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_StartPipelineExecution.html)
  + パラメータ: [https://docs.aws.amazon.com/scheduler/latest/APIReference/API_SageMakerPipelineParameters.html](https://docs.aws.amazon.com/scheduler/latest/APIReference/API_SageMakerPipelineParameters.html)
+ **Amazon SNS** – [https://docs.aws.amazon.com/sns/latest/api/API_Publish.html](https://docs.aws.amazon.com/sns/latest/api/API_Publish.html)
+ **Amazon SQS** – [https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html)
  + パラメータ: [https://docs.aws.amazon.com/scheduler/latest/APIReference/API_SqsParameters.html](https://docs.aws.amazon.com/scheduler/latest/APIReference/API_SqsParameters.html)
+ **Step Functions** – [https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html)

 以下の例では、さまざまなテンプレート化されたターゲットを設定する方法と、説明されている各ターゲットに必要な IAM アクセス許可について説明します。

## Amazon SQS `SendMessage`
<a name="managing-targets-templated-sqs"></a>

**Example 実行ロールのアクセス権限ポリシー**    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "sqs:SendMessage"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}
```

**Example AWS CLI**  

```
$ aws scheduler create-schedule --name sqs-templated --schedule-expression 'rate(5 minutes)' \
--target '{"RoleArn": "{{ROLE_ARN}}", "Arn":"{{QUEUE_ARN}}", "Input": "Message for scheduleArn: '<aws.scheduler.schedule-arn>', scheduledTime: '<aws.scheduler.scheduled-time>'" }' \
--flexible-time-window '{ "Mode": "OFF"}'
```

**Example Python SDK**  

```
import boto3
scheduler = boto3.client('scheduler')

flex_window = { "Mode": "OFF" }

sqs_templated = {
    "RoleArn": "<ROLE_ARN>",
    "Arn": "<QUEUE_ARN>",
    "Input": "Message for scheduleArn: '<aws.scheduler.schedule-arn>', scheduledTime: '<aws.scheduler.scheduled-time>'"
}

scheduler.create_schedule(
    Name="sqs-python-templated",
    ScheduleExpression="rate(5 minutes)",
    Target=sqs_templated,
    FlexibleTimeWindow=flex_window)
```

**Example Java SDK**  

```
package com.example;

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.scheduler.SchedulerClient;
import software.amazon.awssdk.services.scheduler.model.*;


public class MySchedulerApp {

    public static void main(String[] args) {
        
        final SchedulerClient client = SchedulerClient.builder()
                .region(Region.US_WEST_2)
                .build();
        
        Target sqsTarget = Target.builder()
                .roleArn("<ROLE_ARN>")
                .arn("<QUEUE_ARN>")
                .input("Message for scheduleArn: '<aws.scheduler.schedule-arn>', scheduledTime: '<aws.scheduler.scheduled-time>'")
                .build();
        
        CreateScheduleRequest createScheduleRequest = CreateScheduleRequest.builder()
                .name("<SCHEDULE NAME>")
                .scheduleExpression("rate(10 minutes)")
                .target(sqsTarget)
                .flexibleTimeWindow(FlexibleTimeWindow.builder()
                        .mode(FlexibleTimeWindowMode.OFF)
                        .build())
                .build();
                
        client.createSchedule(createScheduleRequest);
        System.out.println("Created schedule with rate expression and an Amazon SQS templated target");
    }
}
```

## Lambda `Invoke`
<a name="managing-targets-templated-lambda"></a>

**Example 実行ロールのアクセス権限ポリシー**    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "lambda:InvokeFunction"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}
```

**Example AWS CLI**  

```
$ aws scheduler create-schedule --name lambda-templated-schedule --schedule-expression 'rate(5 minutes)' \
--target '{"RoleArn": "{{ROLE_ARN}}", "Arn":"{{FUNCTION_ARN}}", "Input": "{ \"Payload\": \"TEST_PAYLOAD\" }" }' \
--flexible-time-window '{ "Mode": "OFF"}'
```

**Example Python SDK**  

```
import boto3
scheduler = boto3.client('scheduler')

flex_window = { "Mode": "OFF" }

lambda_templated = {
    "RoleArn": "<ROLE_ARN>",
    "Arn": "<LAMBDA_ARN>",
    "Input": "{ 'Payload': 'TEST_PAYLOAD' }"}
}

scheduler.create_schedule(
    Name="lambda-python-templated",
    ScheduleExpression="rate(5 minutes)",
    Target=lambda_templated,
    FlexibleTimeWindow=flex_window)
```

**Example Java SDK**  

```
package com.example;

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.scheduler.SchedulerClient;
import software.amazon.awssdk.services.scheduler.model.*;


public class MySchedulerApp {

    public static void main(String[] args) {
        
        final SchedulerClient client = SchedulerClient.builder()
                .region(Region.US_WEST_2)
                .build();
                
        Target lambdaTarget = Target.builder()
                .roleArn("<ROLE_ARN>")
                .arn("<Lambda ARN>")
                .input("{ 'Payload': 'TEST_PAYLOAD' }")
                .build();
        
        CreateScheduleRequest createScheduleRequest = CreateScheduleRequest.builder()
                .name("<SCHEDULE_NAME>")
                .scheduleExpression("rate(10 minutes)")
                .target(lambdaTarget)
                .flexibleTimeWindow(FlexibleTimeWindow.builder()
                        .mode(FlexibleTimeWindowMode.OFF)
                        .build())
                .clientToken("<Token GUID>")
                .build();
                
        client.createSchedule(createScheduleRequest);
        System.out.println("Created schedule with rate expression and Lambda templated target");        
    }
}
```

## Step Functions `StartExecution`
<a name="managing-targets-templated-sfn"></a>

**Example 実行ロールのアクセス権限ポリシー**    
****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "states:StartExecution"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}
```

**Example AWS CLI**  

```
$ aws scheduler create-schedule --name sfn-templated-schedule --schedule-expression 'rate(5 minutes)' \
--target '{"RoleArn": "{{ROLE_ARN}}", "Arn":"{{STATE_MACHINE_ARN}}", "Input": "{ \"Payload\": \"TEST_PAYLOAD\" }" }' \
--flexible-time-window '{ "Mode": "OFF"}'
```

**Example Python SDK**  

```
import boto3
scheduler = boto3.client('scheduler')

flex_window = { "Mode": "OFF" }

sfn_templated= {
    "RoleArn": "<ROLE_ARN>",
    "Arn": "<STATE_MACHINE_ARN>",
    "Input": "{ 'Payload': 'TEST_PAYLOAD' }"
}

scheduler.create_schedule(Name="sfn-python-templated",
    ScheduleExpression="rate(5 minutes)",
    Target=sfn_templated,
    FlexibleTimeWindow=flex_window)
```

**Example Java SDK**  

```
package com.example;

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.scheduler.SchedulerClient;
import software.amazon.awssdk.services.scheduler.model.*;


public class MySchedulerApp {

    public static void main(String[] args) {
        
        final SchedulerClient client = SchedulerClient.builder()
                .region(Region.US_WEST_2)
                .build();
                
        Target stepFunctionsTarget = Target.builder()
                .roleArn("<ROLE_ARN>")
                .arn("<STATE_MACHINE_ARN>")
                .input("{ 'Payload': 'TEST_PAYLOAD' }")
                .build();
        
        CreateScheduleRequest createScheduleRequest = CreateScheduleRequest.builder()
                .name("<SCHEDULE_NAME>")
                .scheduleExpression("rate(10 minutes)")
                .target(stepFunctionsTarget)
                .flexibleTimeWindow(FlexibleTimeWindow.builder()
                        .mode(FlexibleTimeWindowMode.OFF)
                        .build())
                .clientToken("<Token GUID>")
                .build();
                
        client.createSchedule(createScheduleRequest);
        System.out.println("Created schedule with rate expression and Step Function templated target");
    }
}
```