Skip to content

Commit

Permalink
Disable S3 Express support for s3 mb command (#8824)
Browse files Browse the repository at this point in the history
  • Loading branch information
aemous authored Jul 29, 2024
1 parent 03a309f commit fb10493
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-s3-90647.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "``s3``",
"description": "Disable usage of mb command with S3 Express directory buckets."
}
3 changes: 3 additions & 0 deletions awscli/customizations/s3/subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ def _run_main(self, parsed_args, parsed_globals):
raise TypeError("%s\nError: Invalid argument type" % self.USAGE)
bucket, _ = split_s3_bucket_key(parsed_args.path)

if is_s3express_bucket(bucket):
raise ValueError("Cannot use mb command with a directory bucket.")

bucket_config = {'LocationConstraint': self.client.meta.region_name}
params = {'Bucket': bucket}
if self.client.meta.region_name != 'us-east-1':
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/s3/test_mb_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ def test_location_constraint_not_added_on_us_east_1(self):
def test_nonzero_exit_if_invalid_path_provided(self):
command = self.prefix + 'bucket'
self.run_cmd(command, expected_rc=255)

def test_incompatible_with_express_directory_bucket(self):
command = self.prefix + 's3://bucket--usw2-az1--x-s3/'
stderr = self.run_cmd(command, expected_rc=255)[1]
self.assertIn('Cannot use mb command with a directory bucket.', stderr)

0 comments on commit fb10493

Please sign in to comment.