Create-bucket command

Creates a new bucket. Prints the ID of the bucket created.

Optionally stores bucket info, CORS rules and lifecycle rules with the bucket. These can be given as JSON on the command line.

If you want server-side encryption for all of the files that are uploaded to a bucket, you can enable SSE-B2 encryption as a default setting for the bucket. In order to do that pass --defaultServerSideEncryption=SSE-B2. The default algorithm is set to AES256 which can by changed with --defaultServerSideEncryptionAlgorithm parameter. All uploads to that bucket, from the time default encryption is enabled onward, will then be encrypted with SSE-B2 by default.

To disable default bucket encryption, use --defaultServerSideEncryption=none.

If --defaultServerSideEncryption is not provided, default server side encryption is determined by the server.

Note

Note that existing files in the bucket are not affected by default bucket encryption settings.

Use –lifecycleRule to set lifecycle rule for the bucket. Multiple rules can be specified by repeating the option.

–lifecycleRules option is deprecated and cannot be used together with –lifecycleRule.

Requires capability:

  • writeBuckets

  • readBucketEncryption

  • writeBucketEncryption

  • writeBucketRetentions

b2 create-bucket [-h] [--bucketInfo BUCKETINFO] [--corsRules CORSRULES]
                 [--fileLockEnabled] [--replication REPLICATION]
                 [--defaultServerSideEncryption {SSE-B2,none}]
                 [--defaultServerSideEncryptionAlgorithm {AES256}]
                 [--lifecycleRule LIFECYCLERULES | --lifecycleRules LIFECYCLERULES]
                 bucketName {allPublic,allPrivate}

Positional Arguments

bucketName
bucketType

Possible choices: allPublic, allPrivate

Named Arguments

--bucketInfo
--corsRules

If given, the bucket will have a ‘custom’ CORS configuration. Accepts a JSON string.

--fileLockEnabled

If given, the bucket will have the file lock mechanism enabled. This parameter cannot be changed after bucket creation.

Default: False

--replication
--defaultServerSideEncryption

Possible choices: SSE-B2, none

--defaultServerSideEncryptionAlgorithm

Possible choices: AES256

Default: “AES256”

--lifecycleRule

Lifecycle rule in JSON format. Can be supplied multiple times.

--lifecycleRules

(deprecated; use –lifecycleRule instead) List of lifecycle rules in JSON format.