# ScheduleTargetInput

The text or well-formed JSON input passed to the target of the schedule.

Tokens and ContextAttribute may be used in the input.

Obtainable from: ScheduleTargetInput.fromObject, ScheduleTargetInput.fromText

- Source: [`aws-scheduler/lib/input.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-scheduler/lib/input.ts#L9)
- Type last changed: v2.186.0 · 27 Mar 2025

## Example

TypeScript:

```ts
import * as sns from 'aws-cdk-lib/aws-sns';

const topic = new sns.Topic(this, 'Topic');

const payload = {
  message: 'Hello scheduler!',
};

const target = new targets.SnsPublish(topic, {
  input: ScheduleTargetInput.fromObject(payload),
});

new Schedule(this, 'Schedule', {
  schedule: ScheduleExpression.rate(Duration.hours(1)),
  target,
});
```

Python:

```python
import aws_cdk.aws_sns as sns

topic = sns.Topic(self, "Topic")

payload = {
    "message": "Hello scheduler!"
}

target = targets.SnsPublish(topic,
    input=ScheduleTargetInput.from_object(payload)
)

Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.hours(1)),
    target=target
)
```

Java:

```java
import software.amazon.awscdk.services.sns.*;

Topic topic = new Topic(this, "Topic");

Map<String, String> payload = Map.of(
        "message", "Hello scheduler!");

SnsPublish target = SnsPublish.Builder.create(topic)
        .input(ScheduleTargetInput.fromObject(payload))
        .build();

Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.hours(1)))
        .target(target)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.SNS;

var topic = new Topic(this, "Topic");

IDictionary<string, string> payload = new Dictionary<string, string> {
    { "message", "Hello scheduler!" }
};

var target = new SnsPublish(topic, new ScheduleTargetBaseProps {
    Input = ScheduleTargetInput.FromObject(payload)
});

new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Hours(1)),
    Target = target
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import sns "github.com/aws/aws-cdk-go/awscdk"

topic := sns.NewTopic(this, jsii.String("Topic"))

payload := map[string]*string{
	"message": jsii.String("Hello scheduler!"),
}

target := targets.NewSnsPublish(topic, &ScheduleTargetBaseProps{
	Input: awscdk.ScheduleTargetInput_FromObject(payload),
})

awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Hours(jsii.Number(1))),
	Target: Target,
})
```

## Initializer

TypeScript:

```ts
new ScheduleTargetInput()
```

Python:

```python
ScheduleTargetInput()
```

Java:

```java
new ScheduleTargetInput()
```

C# / .NET:

```csharp
new ScheduleTargetInput()
```

Golang:

```go
NewScheduleTargetInput()
```

## Methods

- `bind(schedule: ISchedule): string` — Return the input properties for this input object.

- `fromObject(obj: any): ScheduleTargetInput // chainable` (static) — Pass a JSON object to the target.

  The object will be transformed into a well-formed JSON string in the final template.

  **Parameters**

  - `obj` — object to use to convert to JSON to use as input for the target.

- `fromText(text: string): ScheduleTargetInput // chainable` (static) — Pass simple text to the target.

  For passing complex values like JSON object to a target use method
  `ScheduleTargetInput.fromObject()` instead.

  **Parameters**

  - `text` — Text to use as the input for the target.
