> **Experimental**
>
> `@aws-cdk/integ-tests-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# WaiterStateMachine

A very simple StateMachine construct highly customized to the provider framework.

This is so that this package does not need to depend on aws-stepfunctions module.

The state machine continuously calls the isCompleteHandler, until it succeeds or times out.
The handler is called `maxAttempts` times with an `interval` duration and a `backoffRate` rate.

For example with:
- maxAttempts = 360 (30 minutes)
- interval = 5
- backoffRate = 1 (no backoff)

it will make the API Call every 5 seconds and fail after 360 failures.

If the backoff rate is changed to 2 (for example), it will
- make the first call
- wait 5 seconds
- make the second call
- wait 15 seconds
- etc.

Extends: [Construct](/cdk/api/v2/docs/constructs.Construct.html) › WaiterStateMachine
Implements: [IConstruct](/cdk/api/v2/docs/constructs.IConstruct.html), [IDependable](/cdk/api/v2/docs/constructs.IDependable.html)

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/assertions/waiter-state-machine.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/integ-tests-alpha/lib/assertions/waiter-state-machine.ts#L66)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as integ_tests_alpha from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';
const waiterStateMachine = new integ_tests_alpha.WaiterStateMachine(this, 'MyWaiterStateMachine', /* all optional props */ {
  backoffRate: 123,
  interval: cdk.Duration.minutes(30),
  providerLogLevel: lambda.ApplicationLogLevel.INFO,
  totalTimeout: cdk.Duration.minutes(30),
});
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.integ_tests_alpha as integ_tests_alpha
import aws_cdk as cdk
from aws_cdk import aws_lambda as lambda_

waiter_state_machine = integ_tests_alpha.WaiterStateMachine(self, "MyWaiterStateMachine",
    backoff_rate=123,
    interval=cdk.Duration.minutes(30),
    provider_log_level=lambda_.ApplicationLogLevel.INFO,
    total_timeout=cdk.Duration.minutes(30)
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.integtests.alpha.*;
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.lambda.*;

WaiterStateMachine waiterStateMachine = WaiterStateMachine.Builder.create(this, "MyWaiterStateMachine")
        .backoffRate(123)
        .interval(Duration.minutes(30))
        .providerLogLevel(ApplicationLogLevel.INFO)
        .totalTimeout(Duration.minutes(30))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.IntegTests.Alpha
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.IntegTests.Alpha;
using Amazon.CDK;
using Amazon.CDK.AWS.Lambda;

var waiterStateMachine = new WaiterStateMachine(this, "MyWaiterStateMachine", new WaiterStateMachineProps {
    BackoffRate = 123,
    Interval = Duration.Minutes(30),
    ProviderLogLevel = ApplicationLogLevel.INFO,
    TotalTimeout = Duration.Minutes(30)
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import integ_tests_alpha "github.com/aws/aws-cdk-go/awscdkintegtestsalpha"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

waiterStateMachine := integ_tests_alpha.NewWaiterStateMachine(this, jsii.String("MyWaiterStateMachine"), &WaiterStateMachineProps{
	BackoffRate: jsii.Number(123),
	Interval: cdk.Duration_Minutes(jsii.Number(30)),
	ProviderLogLevel: awscdk.Aws_lambda.ApplicationLogLevel_INFO,
	TotalTimeout: cdk.Duration_*Minutes(jsii.Number(30)),
})
```

## Initializer

TypeScript:

```ts
new WaiterStateMachine(scope: Construct, id: string, props?: WaiterStateMachineProps)
```

Python:

```python
WaiterStateMachine(scope: Construct, id: str, props: typing.Optional[WaiterStateMachineProps] = None)
```

Java:

```java
new WaiterStateMachine(Construct scope, String id, WaiterStateMachineProps props)
```

C# / .NET:

```csharp
new WaiterStateMachine(Construct scope, string id, WaiterStateMachineProps? props = null)
```

Golang:

```go
NewWaiterStateMachine(Scope Construct, Id *string, Props WaiterStateMachineProps)
```

## Construct Props

- `backoffRate`: number — Backoff between attempts.

  **Default:** 1 (no backoff)

  This is the multiplier by which the retry interval increases
  after each retry attempt.

  By default there is no backoff. Each retry will wait the amount of time
  specified by `interval`.

- `interval`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(5) — The interval (number of seconds) to wait between attempts.

- `providerLogLevel`: [ApplicationLogLevel](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ApplicationLogLevel.html) = ApplicationLogLevel.FATAL — The log level of the provider lambda function.

- `totalTimeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.minutes(30) — The total time that the state machine will wait for a successful response.

## Properties

- `isCompleteProvider`: [AssertionsProvider](/cdk/api/v2/docs/@aws-cdk_integ-tests-alpha.AssertionsProvider.html) — The AssertionsProvide that handles async requests.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `roleArn`: string — The IAM Role ARN of the role used by the state machine.

- `stateMachineArn`: string — The ARN of the statemachine.

## Methods

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
