Skip to content
v2.274.0

ObjectLockRetention Class ​

The default retention settings for an S3 Object Lock configuration.

Example ​

ts
// Configure for governance mode with a duration of 7 years
new s3.Bucket(this, 'Bucket1', {
  objectLockDefaultRetention: s3.ObjectLockRetention.governance(Duration.days(7 * 365)),
});

// Configure for compliance mode with a duration of 1 year
new s3.Bucket(this, 'Bucket2', {
  objectLockDefaultRetention: s3.ObjectLockRetention.compliance(Duration.days(365)),
});

Properties ​

durationDurationdurationDurationdurationDurationDurationDurationDurationDurationrequired#
The default period for which objects should be retained.
The retention mode to use for the object lock configuration.

Methods ​

compliance(duration: Duration): ObjectLockRetention // chainable@staticmethod def compliance(duration: Duration) -> ObjectLockRetentionpublic static ObjectLockRetention compliance(Duration duration)public static ObjectLockRetention Compliance(Duration duration)func Compliance(Duration Duration) ObjectLockRetentionstatic#
Configure for Compliance retention for a specified duration.
notes · 1 parameter · returns

When an object is locked in compliance mode, its retention mode can't be changed, and its retention period can't be shortened. Compliance mode helps ensure that an object version can't be overwritten or deleted for the duration of the retention period.

Parameters

  • durationdurationdurationdurationDuration — the length of time for which objects should be retained.

Returns: the ObjectLockRetention configuration

governance(duration: Duration): ObjectLockRetention // chainable@staticmethod def governance(duration: Duration) -> ObjectLockRetentionpublic static ObjectLockRetention governance(Duration duration)public static ObjectLockRetention Governance(Duration duration)func Governance(Duration Duration) ObjectLockRetentionstatic#
Configure for Governance retention for a specified duration.
notes · 1 parameter · returns

With governance mode, you protect objects against being deleted by most users, but you can still grant some users permission to alter the retention settings or delete the object if necessary. You can also use governance mode to test retention-period settings before creating a compliance-mode retention period.

Parameters

  • durationdurationdurationdurationDuration — the length of time for which objects should retained.

Returns: the ObjectLockRetention configuration