# SecretRotationProps

Construction properties for a SecretRotation.

Extends: SecretRotationProps
Used as props by: SecretRotation

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

## Example

```ts
declare const myUserSecret: secretsmanager.Secret;
declare const myMasterSecret: secretsmanager.Secret;
declare const myDatabase: ec2.IConnectable;
declare const myVpc: ec2.Vpc;

new secretsmanager.SecretRotation(this, 'SecretRotation', {
  application: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_MULTI_USER,
  secret: myUserSecret, // The secret that will be rotated
  masterSecret: myMasterSecret, // The secret used for the rotation
  target: myDatabase,
  vpc: myVpc,
});
```

## Properties

- `application`: [SecretRotationApplication](/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.SecretRotationApplication.html) (required) — The serverless application for the rotation.

- `automaticallyAfter`: [Duration](/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.

- `endpoint`: [IInterfaceVpcEndpoint](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IInterfaceVpcEndpoint.html) — The VPC interface endpoint to use for the Secrets Manager API.

  **Default:** https://secretsmanager.<region>.amazonaws.com

  If you enable private DNS hostnames for your VPC private endpoint (the default), you don't
  need to specify an endpoint. The standard Secrets Manager DNS hostname the Secrets Manager
  CLI and SDKs use by default (https://secretsmanager.<region>.amazonaws.com) automatically
  resolves to your VPC endpoint.

- `excludeCharacters`: string — Characters which should not appear in the generated password.

  **Default:** no additional characters are explicitly excluded

- `masterSecret`: [ISecret](/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html) — The master secret for a multi user rotation scheme.

  **Default:** single user rotation scheme

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

- `secret`: [ISecret](/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html) (required) — The secret to rotate. It must be a JSON string with the following format:.

  ```
  {
    "engine": <required: database engine>,
    "host": <required: instance host name>,
    "username": <required: username>,
    "password": <required: password>,
    "dbname": <optional: database name>,
    "port": <optional: if not specified, default port will be used>,
    "masterarn": <required for multi user rotation: the arn of the master secret which will be used to create users/change passwords>
  }
  ```

  This is typically the case for a secret referenced from an `AWS::SecretsManager::SecretTargetAttachment`
  or an `ISecret` returned by the `attach()` method of `Secret`.

- `securityGroup`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html) — The security group for the Lambda rotation function.

  **Default:** a new security group is created

- `target`: [IConnectable](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IConnectable.html) (required) — The target service or database.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC where the Lambda rotation function will run.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — The type of subnets in the VPC where the Lambda rotation function will run.

  **Default:** the Vpc default strategy if not specified.
