

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Utilizzo di obiettivi basati su modelli in Scheduler EventBridge
<a name="managing-targets-templated"></a>

 *Gli obiettivi basati su modelli* sono un insieme di operazioni API comuni su un gruppo di AWS servizi principali, come Amazon SQS, Lambda e Step Functions. Ad esempio, puoi indirizzare l'[https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke)operazione di Lambda fornendo la funzione ARN o l'operazione di Amazon SQS utilizzando l'ARN [https://docs.aws.amazon.com/](https://docs.aws.amazon.com/)della coda. Per configurare un target basato su modelli, devi anche concedere le autorizzazioni al ruolo di esecuzione della pianificazione per eseguire l'operazione API di destinazione. 

 Per configurare una destinazione basata su modelli in modo programmatico utilizzando AWS CLI o uno degli EventBridge Scheduler SDKs, è necessario specificare l'ARN del ruolo di esecuzione, l'ARN per la risorsa di destinazione, un input opzionale che si desidera che EventBridge Scheduler fornisca alla destinazione e, per alcune destinazioni basate su modelli, un set unico di parametri con opzioni di configurazione aggiuntive per tale destinazione. Quando si specifica l'ARN per una risorsa di destinazione basata su modelli, EventBridge Scheduler presuppone automaticamente che si desideri chiamare l'operazione API supportata per quel servizio. [Se si desidera che EventBridge Scheduler utilizzi come destinazione un'operazione API diversa per il servizio, è necessario configurare la destinazione come destinazione universale.](managing-targets-universal.md) 

 Di seguito è riportato un elenco completo di tutte le destinazioni basate su modelli supportate da EventBridge Scheduler e, se applicabile, del set unico di parametri associati a ciascuna destinazione. Scegli il link per ogni set di parametri per visualizzare i campi obbligatori e facoltativi nello *EventBridge Scheduler* API Reference. 
+ **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)
  + Parametri: [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)
  + Parametri: [https://docs.aws.amazon.com/scheduler/latest/APIReference/API_EventBridgeParameters.html](https://docs.aws.amazon.com/scheduler/latest/APIReference/API_EventBridgeParameters.html)
+ **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)
  + Parametri: [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 IA** — [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_StartPipelineExecution.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_StartPipelineExecution.html)
  + Parametri: [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)
  + Parametri: [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)

 Utilizza i seguenti esempi per imparare a configurare diversi target basati su modelli e le autorizzazioni IAM richieste per ogni destinazione descritta. 

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

**Example Politica di autorizzazione per il ruolo di esecuzione**    
****  

```
{
    "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 SDK Java**  

```
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 Politica di autorizzazione per il ruolo di esecuzione**    
****  

```
{
    "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 SDK Java**  

```
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 Politica di autorizzazione per il ruolo di esecuzione**    
****  

```
{
    "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 SDK Java**  

```
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");
    }
}
```