Skip to content

Commit

Permalink
Explicit empty bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Oct 31, 2024
1 parent 2577d7a commit dd686af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions packages/@aws-cdk-testing/cli-integ/lib/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class AwsClients {
}
}

public async emptyBucket(bucketName: string) {
public async emptyBucket(bucketName: string, options?: { bypassGovernance?: boolean }) {
const objects = await this.s3.send(
new ListObjectVersionsCommand({
Bucket: bucketName,
Expand All @@ -154,8 +154,7 @@ export class AwsClients {
Objects: deletes,
Quiet: false,
},
// Necessary for the test that adds Object Lock to a bucket
BypassGovernanceRetention: true,
BypassGovernanceRetention: options?.bypassGovernance ? true : undefined,
}),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,9 @@ integTest('deploy stack with Lambda Asset to Object Lock-enabled asset bucket',
],
});

// THEN - should not fail
// THEN - should not fail. Now clean the bucket with governance bypass: a regular delete
// operation will fail.
await fixture.aws.emptyBucket(bucketName, { bypassGovernance: true });
}));

integTest(
Expand Down

0 comments on commit dd686af

Please sign in to comment.