# RotationScheduleOptions

Options to add a rotation schedule to a secret.

Used as argument in: [ISecret.addRotationSchedule](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html#addrotationschedule)

- Source: [`aws-secretsmanager/lib/rotation-schedule.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-secretsmanager/lib/rotation-schedule.ts#L26)
- Type last changed: v2.88.0 · 20 Jul 2023

## Example

TypeScript:

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

declare const fn: lambda.Function;
const secret = new secretsmanager.Secret(this, 'Secret');

secret.addRotationSchedule('RotationSchedule', {
  rotationLambda: fn,
  automaticallyAfter: Duration.days(15),
  rotateImmediatelyOnUpdate: false, // default is true
});
```

Python:

```python
import aws_cdk.aws_lambda as lambda_

# fn: lambda.Function

secret = secretsmanager.Secret(self, "Secret")

secret.add_rotation_schedule("RotationSchedule",
    rotation_lambda=fn,
    automatically_after=Duration.days(15),
    rotate_immediately_on_update=False
)
```

Java:

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

Function fn;

Secret secret = new Secret(this, "Secret");

secret.addRotationSchedule("RotationSchedule", RotationScheduleOptions.builder()
        .rotationLambda(fn)
        .automaticallyAfter(Duration.days(15))
        .rotateImmediatelyOnUpdate(false)
        .build());
```

C# / .NET:

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

Function fn;

var secret = new Secret(this, "Secret");

secret.AddRotationSchedule("RotationSchedule", new RotationScheduleOptions {
    RotationLambda = fn,
    AutomaticallyAfter = Duration.Days(15),
    RotateImmediatelyOnUpdate = false
});
```

Golang:

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

var fn Function

secret := secretsmanager.NewSecret(this, jsii.String("Secret"))

secret.addRotationSchedule(jsii.String("RotationSchedule"), &RotationScheduleOptions{
	RotationLambda: fn,
	AutomaticallyAfter: awscdk.Duration_Days(jsii.Number(15)),
	RotateImmediatelyOnUpdate: jsii.Boolean(false),
})
```

## Properties

- `automaticallyAfter`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.days(30) — Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation.

  The minimum value is 4 hours.
  The maximum value is 1000 days.

  A value of zero (`Duration.days(0)`) will not create RotationRules.

- `hostedRotation`: [HostedRotation](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.HostedRotation.html) — Hosted rotation.

  **Default:** either `rotationLambda` or `hostedRotation` must be specified

- `rotateImmediatelyOnUpdate`: boolean = true — Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window.

- `rotationLambda`: [IFunction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — A Lambda function that can rotate the secret.

  **Default:** either `rotationLambda` or `hostedRotation` must be specified
