Creates a bucket.
Usage notes
To create a bucket, you must have the
oss:PutBucket
permission. For more information, see Attach a custom policy to a RAM user.You can create up to 100 buckets in the same region by using an Alibaba Cloud account.
Each region can be accessed by using the corresponding endpoints. For more information, see Regions and endpoints.
Command syntax
ossutil api put-bucket --bucket value [flags]
Parameter | Type | Description |
--acl | string | The access control list (ACL) of the bucket. |
--bucket | string | The name of the bucket. |
--create-bucket-configuration | string | The container that stores the information about the bucket. |
--resource-group-id | string | The ID of the resource group. |
The put-bucket command provides access to the PutBucket operation. For more information about the API operation, see PutBucket.
--create-bucket-configuration
The --create-bucket-configuration parameter supports configuration options in the XML and JSON formats:
XML format:
<?xml version="1.0" encoding="UTF-8"?> <CreateBucketConfiguration> <StorageClass>Standard</StorageClass> <DataRedundancyType>LRS</DataRedundancyType> </CreateBucketConfiguration>
JSON format:
{ "StorageClass": "Standard", "DataRedundancyType": "LRS" }
For more information, see Command-line options.
Examples
Create a bucket named examplebucket.
ossutil api put-bucket --bucket examplebucket
Create a bucket named examplebucket and set its ACL to private, resource group to rg-123, storage class to Standard, and redundancy type to locally redundant storage (LRS).
Use an XML configuration file (create-bucket-configuration.xml)
<?xml version="1.0" encoding="UTF-8"?> <CreateBucketConfiguration> <StorageClass>Standard</StorageClass> <DataRedundancyType>LRS</DataRedundancyType> </CreateBucketConfiguration>
Sample command:
ossutil api put-bucket --bucket examplebucket --acl private --resource-group-id rg-123 --create-bucket-configuration file://create-bucket-configuration.xml
Use a JSON configuration file (create-bucket-configuration.json)
{ "StorageClass": "Standard", "DataRedundancyType": "LRS" }
Sample command:
ossutil api put-bucket --bucket examplebucket --acl private --resource-group-id rg-123 --create-bucket-configuration file://create-bucket-configuration.json
Use JSON parameters in the command line
ossutil api put-bucket --bucket examplebucket --acl private --resource-group-id rg-123 --create-bucket-configuration "{\"StorageClass\":\"Standard\",\"DataRedundancyType\":\"LRS\"}"