AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

SecretRotation

Secret rotation for a service or database.

Import

import { SecretRotation } from 'aws-cdk-lib/aws-secretsmanager';

Or use the module namespace:

import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
// secretsmanager.SecretRotation

Properties

Configuration passed to the constructor as SecretRotationProps.

applicationRequired
SecretRotationApplication

The serverless application for the rotation.

secretRequired
ISecret

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`.

targetRequired
IConnectable

The target service or database.

vpcRequired
IVpc

The VPC where the Lambda rotation function will run.

automaticallyAfterOptional
Duration

Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation.

Default: Duration.days(30)

endpointOptional
IInterfaceVpcEndpoint

The VPC interface endpoint to use for the Secrets Manager API. 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.

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

excludeCharactersOptional
string

Characters which should not appear in the generated password.

Default: - no additional characters are explicitly excluded

masterSecretOptional
ISecret

The master secret for a multi user rotation scheme.

Default: - single user rotation scheme

rotateImmediatelyOnUpdateOptional
boolean

Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window.

Default: true

securityGroupOptional
ISecurityGroup

The security group for the Lambda rotation function.

Default: - a new security group is created

vpcSubnetsOptional
SubnetSelection

The type of subnets in the VPC where the Lambda rotation function will run.

Default: - the Vpc default strategy if not specified.

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter