Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Oct 12, 2023
1 parent e95b32a commit aa26213
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions packages/aws-cdk-lib/aws-secretsmanager/lib/rotation-schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,19 @@ export class RotationSchedule extends Resource {
// Prevent secrets deletions when rotation is in place
props.secret.denyAccountRootDelete();

if (props.automaticallyAfter && props.automaticallyAfter.toMilliseconds() === 0) {
return;
if (!props.automaticallyAfter || props.automaticallyAfter.toMilliseconds() !== 0) {
const rotationRules = {
automaticallyAfterDays: props.automaticallyAfter?.toDays() || 30,
};

new CfnRotationSchedule(this, 'Resource', {
secretId: props.secret.secretArn,
rotationLambdaArn: props.rotationLambda?.functionArn,
hostedRotationLambda: props.hostedRotation?.bind(props.secret, this),
rotationRules,
rotateImmediatelyOnUpdate: props.rotateImmediatelyOnUpdate,
});
}

const rotationRules = {
automaticallyAfterDays: props.automaticallyAfter?.toDays() || 30,
};

new CfnRotationSchedule(this, 'Resource', {
secretId: props.secret.secretArn,
rotationLambdaArn: props.rotationLambda?.functionArn,
hostedRotationLambda: props.hostedRotation?.bind(props.secret, this),
rotationRules,
rotateImmediatelyOnUpdate: props.rotateImmediatelyOnUpdate,
});
}
}

Expand Down

0 comments on commit aa26213

Please sign in to comment.