MCPcopy Create free account
hub / github.com/aws/aws-cli / _run_main

Method _run_main

awscli/customizations/s3/subcommands.py:1252–1292  ·  view source on GitHub ↗
(self, parsed_args, parsed_globals)

Source from the content-addressed store, hash-verified

1250 ] + [TAGS]
1251
1252 def _run_main(self, parsed_args, parsed_globals):
1253 super(MbCommand, self)._run_main(parsed_args, parsed_globals)
1254
1255 if not parsed_args.path.startswith('s3://'):
1256 raise ParamValidationError(
1257 "%s\nError: Invalid argument type" % self.USAGE
1258 )
1259 bucket, _ = split_s3_bucket_key(parsed_args.path)
1260
1261 if is_s3express_bucket(bucket):
1262 raise ParamValidationError(
1263 "Cannot use mb command with a directory bucket."
1264 )
1265
1266 params = {'Bucket': bucket}
1267 bucket_config = {}
1268 bucket_tags = self._create_bucket_tags(parsed_args)
1269
1270 if is_account_regional_namespace_bucket(bucket):
1271 params['BucketNamespace'] = 'account-regional'
1272
1273 # Only set LocationConstraint when the region name is not us-east-1.
1274 # Sending LocationConstraint with value us-east-1 results in an error.
1275 if self.client.meta.region_name != 'us-east-1':
1276 bucket_config['LocationConstraint'] = self.client.meta.region_name
1277 if bucket_tags:
1278 bucket_config['Tags'] = bucket_tags
1279 if bucket_config:
1280 params['CreateBucketConfiguration'] = bucket_config
1281
1282 # TODO: Consolidate how we handle return codes and errors
1283 try:
1284 self.client.create_bucket(**params)
1285 uni_print("make_bucket: %s\n" % bucket)
1286 return 0
1287 except Exception as e:
1288 uni_print(
1289 "make_bucket failed: %s %s\n" % (parsed_args.path, e),
1290 sys.stderr,
1291 )
1292 return 1
1293
1294 def _create_bucket_tags(self, parsed_args):
1295 if parsed_args.tags is not None:

Callers

nothing calls this directly

Calls 8

_create_bucket_tagsMethod · 0.95
split_s3_bucket_keyFunction · 0.90
is_s3express_bucketFunction · 0.90
uni_printFunction · 0.90
_run_mainMethod · 0.45
create_bucketMethod · 0.45

Tested by

no test coverage detected