> **Experimental**
>
> `@aws-cdk/aws-iotevents-actions-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# TimerDuration

The duration of the timer.

Obtainable from: TimerDuration.fromDuration, TimerDuration.fromExpression
Used as argument in: [SetTimerAction (initializer)](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-iotevents-actions-alpha.SetTimerAction.html#initializer)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/timer-duration.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-iotevents-actions-alpha/lib/timer-duration.ts#L7)

## Example

TypeScript:

```ts
import * as iotevents from '@aws-cdk/aws-iotevents-alpha';
import * as actions from '@aws-cdk/aws-iotevents-actions-alpha';

declare const input: iotevents.IInput;

const state = new iotevents.State({
  stateName: 'MyState',
  onEnter: [{
    eventName: 'test-event',
    condition: iotevents.Expression.currentInput(input),
    actions: [
      new actions.SetTimerAction('MyTimer', {
        duration: cdk.Duration.seconds(60),
      }),
    ],
  }],
});
```

Python:

```python
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions

# input: iotevents.IInput

state = iotevents.State(
    state_name="MyState",
    on_enter=[iotevents.Event(
        event_name="test-event",
        condition=iotevents.Expression.current_input(input),
        actions=[
            actions.SetTimerAction("MyTimer", {
                "duration": cdk.Duration.seconds(60)
            })
        ]
    )]
)
```

Java:

```java
import software.amazon.awscdk.services.iotevents.alpha.*;
import software.amazon.awscdk.services.iotevents.actions.alpha.*;

IInput input;

State state = State.Builder.create()
        .stateName("MyState")
        .onEnter(List.of(Event.builder()
                .eventName("test-event")
                .condition(Expression.currentInput(input))
                .actions(List.of(
                    new SetTimerAction("MyTimer", Map.of(
                            "duration", cdk.Duration.seconds(60)))))
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.IoTEvents.Actions.Alpha
using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IoTEvents.Actions.Alpha;

IInput input;

var state = new State(new StateProps {
    StateName = "MyState",
    OnEnter = new [] { new Event {
        EventName = "test-event",
        Condition = Expression.CurrentInput(input),
        Actions = new [] {
            new SetTimerAction("MyTimer", new Dictionary<string, object> {
                { "duration", cdk.Duration.Seconds(60) }
            }) }
    } }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkioteventsactionsalpha/v2
import "github.com/aws/aws-cdk-go/awscdkioteventsalpha"
import actions "github.com/aws/aws-cdk-go/awscdkioteventsactionsalpha"

var input IInput

state := iotevents.NewState(&StateProps{
	StateName: jsii.String("MyState"),
	OnEnter: []Event{
		&Event{
			EventName: jsii.String("test-event"),
			Condition: iotevents.Expression_CurrentInput(input),
			Actions: []IAction{
				actions.NewSetTimerAction(jsii.String("MyTimer"), map[string]interface{}{
					"duration": cdk.Duration_seconds(jsii.Number(60)),
				}),
			},
		},
	},
})
```

## Initializer

TypeScript:

```ts
new TimerDuration()
```

Python:

```python
TimerDuration()
```

Java:

```java
new TimerDuration()
```

C# / .NET:

```csharp
new TimerDuration()
```

Golang:

```go
NewTimerDuration()
```

## Methods

- `fromDuration(duration: Duration): TimerDuration // chainable` (static) — Create a timer-duration from Duration.

  The range of the duration is 60-31622400 seconds.
  The evaluated result of the duration expression is rounded down to the nearest whole number.
  For example, if you set the timer to 60.99 seconds, the evaluated result of the duration expression is 60 seconds.

- `fromExpression(expression: Expression): TimerDuration // chainable` (static) — Create a timer-duration from Expression.

  You can use a string expression that includes numbers, variables ($variable.<variable-name>),
  and input values ($input.<input-name>.<path-to-datum>) as the duration.

  The range of the duration is 60-31622400 seconds.
  The evaluated result of the duration expression is rounded down to the nearest whole number.
  For example, if you set the timer to 60.99 seconds, the evaluated result of the duration expression is 60 seconds.
