Skip to content

Commit

Permalink
feat(cdk): allow setting bucket versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Aug 23, 2024
1 parent 054e563 commit e15e351
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/cdk/src/methods/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface AddBucketOptions {
* If true, enables static website hosting for the bucket. An `index.html` file must exist within the bucket contents.
*/
staticHosting?: boolean;
/* If true, turns on bucket versioning. This is required if using addBackup with the bucket */
versioning?: boolean;
}

interface AddBucketResult {
Expand Down Expand Up @@ -97,7 +99,8 @@ export const addBucket = (options: AddBucketOptions): AddBucketResult => {
publicReadAccess,
retain = false,
staticHosting,
scope
scope,
versioning = false
} = options;

if (autoDeleteObjects && retain)
Expand Down Expand Up @@ -153,6 +156,10 @@ export const addBucket = (options: AddBucketOptions): AddBucketResult => {
lifecycleRules,
publicReadAccess,
removalPolicy,
// Note: If this is ever used with a bucket that accepts overwriting existing objects,
// then lifecycle rules need to be added. That's not something I've ever done so we're
// leaving that alone for now
versioned: versioning,
websiteIndexDocument
};

Expand Down

0 comments on commit e15e351

Please sign in to comment.