Delete Amazon S3 Buckets with Versioning | SysOps Administrator Exam

Deleting Amazon S3 Buckets with Versioning

Question

You are working as a SysOps administrator for a media company.

Your company is using Amazon S3 buckets to save video content shared by reporters.

For each month, a new bucket is created as an example-bucket-monthname.

For the month of July, all these data are stored in bucket name as “example-bucket-july” which has versioning enabled.

At the start of a new month, data for last month along with the bucket needs to be deleted to free up space.

Which of the following can be used to meet this requirement?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: A.

Since all the buckets have versioning enabled, the following can be used to delete the S3 bucket.

· Delete the bucket programmatically using the AWS SDK.

· Use the bucket's lifecycle configuration to request that Amazon S3 delete the objects.

· Use the Amazon S3 console.

Option B is incorrect as this command will not be successful in this case as the S3 bucket has versioning enabled.

All content needs to be removed before a bucket is removed.

Option C is incorrect as this command will be successful only if you are deleting a bucket that does not have versioning enabled.

Option D is incorrect as this will remove all objects in a bucket only if the bucket does not have versioning enabled.

For more information on using the CLI with Amazon S3, refer to the following URLs-

https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html https://docs.aws.amazon.com/AmazonS3/latest/dev/delete-or-empty-bucket.html

Option D is the correct answer: "Delete bucket using command “$ aws s3 rm s3:// example-bucket-july --recursive”."

Explanation:

To free up space at the start of each month, the bucket for the previous month along with its data needs to be deleted. The bucket name includes the month name as part of its name. In this scenario, the bucket name is "example-bucket-july", which means it contains data for the month of July.

There are multiple ways to delete the bucket and its contents, but only one of the given options is correct. Let's evaluate each option one by one.

Option A: Delete bucket example-bucket-july programmatically using AWS SDK. This option is incorrect because deleting the bucket programmatically using AWS SDK will only delete the bucket and not its contents. Therefore, it will not free up space as required.

Option B: Delete bucket using the command “$ aws s3 rb s3://example-bucket-july --force” This option is incorrect because the "--force" option will bypass the confirmation prompt and delete the bucket even if it is not empty. However, it will not delete the contents of the bucket, which means it will not free up space as required.

Option C: Delete bucket using the command “$ aws s3 rb s3:// example-bucket-july” This option is incorrect because it will only delete the bucket if it is empty. Since the bucket contains data for the month of July, it will not be empty, and the command will fail to delete the bucket.

Option D: Delete bucket using command “$ aws s3 rm s3:// example-bucket-july --recursive” This option is correct because the "--recursive" option will delete all the contents of the bucket along with the bucket itself. Therefore, it will free up space as required.

In summary, the correct option to meet the requirement of freeing up space at the start of each month is to use the command “$ aws s3 rm s3:// example-bucket-july --recursive”.