Creating a Bucket
Create a bucket to store objects within an Object Storage namespace.
The bucket is created immediately and you can start uploading objects to it. Objects added to archive buckets are immediately archived and must be restored before they are available for download.
Creating a Standard default storage tier bucket
By default, a bucket is created in the Standard Object Storage tier. You do not need to explicitly set
--storage-tier
. Standard is the primary, default storage tier used for Object Storage service data. Use the Standard tier for storing data that requires fast and immediate access. Standard buckets do, however, provide an option to assign and upload objects to different storage tiers (Infrequent Access and Archive), while remaining in the Standard bucket.oci os bucket create --namespace <object_storage_namespace> --name <bucket_name> --compartment-id <target_compartment_id>
For example:
oci os bucket create --namespace MyNamespace --name MyStandardBucket --compartment-id ocid.compartment.oc1..exampleuniqueID { "data": { "approximate-count": null, "approximate-size": null, "auto-tiering": null, "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": {}, "etag": "7b7c3dc1-713f-4996-b176-a938345cae8e", "freeform-tags": {}, "id": "ocid1.bucket.oc1..exampleuniqueID", "is-read-only": false, "kms-key-id": null, "metadata": {}, "name": "MyStandardBucket", "namespace": "MyNamespace", "object-events-enabled": false, "object-level-audit-mode": "Disabled", "object-lifecycle-policy-etag": null, "public-access-type": "NoPublicAccess", "replication-enabled": false, "storage-tier": "Standard", "time-created": "2020-06-12T19:04:05.879000+00:00", "versioning": "Disabled" }, "etag": "7b7c3dc1-713f-4996-b176-a938345cae8e" }
You can also enable Auto-Tiering on a Standard bucket at creation time by specifying the optional--auto-tiering InfrequentAccess
parameter. See Enabling Auto-Tiering for details. For example:oci os bucket create --namespace MyNamespace --name MyStandardBucket --compartment-id ocid.compartment.oc1..exampleuniqueID --auto-tiering Infrequent Access { "data": { "approximate-count": null, "approximate-size": null, "auto-tiering": "InfrequentAccess", "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": {}, "etag": "7b7c3dc1-713f-4996-b176-a938345cae8e", "freeform-tags": {}, "id": "ocid1.bucket.oc1..exampleuniqueID", "is-read-only": false, "kms-key-id": null, "metadata": {}, "name": "MyStandardBucket", "namespace": "MyNamespace", "object-events-enabled": false, "object-level-audit-mode": "Disabled", "object-lifecycle-policy-etag": null, "public-access-type": "NoPublicAccess", "replication-enabled": false, "storage-tier": "Standard", "time-created": "2020-06-12T19:04:05.879000+00:00", "versioning": "Disabled" }, "etag": "7b7c3dc1-713f-4996-b176-a938345cae8e" }
A Standard tier bucket is created immediately and you can start uploading objects.Creating an Archive default storage tier bucket
To create an Archive tier bucket, you must explicitly set
--storage-tier Archive
. Archive is the default storage tier used for Archive Storage service data. Use the Archive tier for storing data that does not require immediate access, but requires long retention periods. Access to data in the Archive tier is not immediate. Archived data must be restored before the data is accessible.oci os bucket create --namespace <object_storage_namespace> --name <archivebucket_name> --compartment-id <target_compartment_id> --storage-tier Archive
For example:
oci os bucket create --namespace MyNamespace --name MyArchiveBucket --compartment-id ocid.compartment.oc1..exampleuniqueID { "data": { "approximate-count": null, "approximate-size": null, "auto-tiering": null, "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": {}, "etag": "7b7c3dc1-713f-4996-b176-a938345cae8e", "freeform-tags": {}, "id": "ocid1.bucket.oc1..exampleuniqueID", "is-read-only": false, "kms-key-id": null, "metadata": {}, "name": "MyArchiveBucket", "namespace": "MyNamespace", "object-events-enabled": false, "object-level-audit-mode": "Disabled", "object-lifecycle-policy-etag": null, "public-access-type": "NoPublicAccess", "replication-enabled": false, "storage-tier": "Archive", "time-created": "2020-06-12T19:04:05.879000+00:00", "versioning": "Disabled" }, "etag": "c8889cd1-8414-41fb-84b7-3738c39e62c5" }
An Archive Storage bucket is created and you can start uploading objects. Objects uploaded to Archive Storage buckets are immediately archived and must be restored before they are available for download.
Creating Public Bucket (Listing and Downloading Bucket Objects)
To create a public bucket that allows listing and downloading bucket objects, you must explicitly set --public-access-type ObjectRead
.oci os bucket create --namespace <object_storage_namespace> --name <bucket_name> --compartment-id <target_compartment_id> --public-access-type ObjectRead
For example:
oci os bucket create --namespace MyNamespace --name MyBucket --compartment-id ocid.compartment.oc1..exampleuniqueID { "data": { "approximate-count": null, "approximate-size": null, "auto-tiering": null, "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": {}, "etag": "01096e0b-659a-4d9d-a806-d57568cf1b22", "freeform-tags": {}, "id": "ocid1.bucket.oc1..exampleuniqueID", "is-read-only": false, "kms-key-id": null, "metadata": {}, "name": "MyPublicObjectReadBucket", "namespace": "MyNamespace", "object-events-enabled": false, "object-lifecycle-policy-etag": null, "public-access-type": "ObjectRead", "replication-enabled": false, "storage-tier": "Standard", "time-created": "2020-06-22T19:04:05.879000+00:00", "versioning": "Disabled" }, "etag": "01096e0b-659a-4d9d-a806-d57568cf1b22" }
Creating Public Bucket (Downloading Bucket Objects)
oci os bucket create --namespace <object_storage_namespace> --name <bucket_name> --compartment-id <target_compartment_id> --public-access-type ObjectReadWithoutList
For example:
oci os bucket create --namespace MyNamespace --name MyPublicObjectReadBucket --compartment-id ocid.compartment.oc1..exampleuniqueID --public-access-type ObjectReadWithoutList{ { "data": { "approximate-count": null, "approximate-size": null, "auto-tiering": null, "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": {}, "etag": "ec20c59a-f5ba-4a6d-8a7e-b69bb9bb76ad", "freeform-tags": {}, "id": "ocid1.bucket.oc1..exampleuniqueID", "is-read-only": false, "kms-key-id": null, "metadata": {}, "name": "MyPublicObjectReadWithoutListBucket", "namespace": "MyNamespace", "object-events-enabled": false, "object-lifecycle-policy-etag": null, "public-access-type": "ObjectReadWithoutList", "replication-enabled": false, "storage-tier": "Standard", "time-created": "2020-06-22T20:18:29.203000+00:00", "versioning": "Disabled" }, "etag": "ec20c59a-f5ba-4a6d-8a7e-b69bb9bb76ad" }
Creating a Bucket with Resource Tags
You can create standard Object Storage tier or Archive tier buckets with resource tags.
To add resource tags when creating a bucket, set one or both of the
--defined-tags
and--freeform-tags
options.Tip
The--defined-tags
and--freeform-tags
options require that the input to be a complex type formatted in valid JSON. See Passing Complex Input and Using a JSON File for Complex Input for information about JSON formatting.The following example syntax creates a standard Object Storage tier bucket with a defined tag:
oci os bucket create --namespace <object_storage_namespace> --name <bucket_name> --compartment-id <target_compartment_id> --defined-tags '<JSON_formatted_defined_tag>'
Examples of defined tag formatting:
'{"Operations": {"CostCenter": "42"}'
'{"Logistics": {"Procurement": "Madrid Center"}},"Financials":{"Production": "Unit 5"}}'
Note
If you are running the CLI on a Windows computer, you might need to use the backslash (\) character to escape the strings containing the tag values. For example, a single defined tag is formatted'{\"Logistics\": {\"Procurement\": \"Madrid Center\"}}'
For example:
oci os bucket create --namespace MyNamespace --name MyBucketDefined --compartment-id ocid.compartment.oc1..exampleuniqueID --defined-tags {"Operations": {"CostCenter": "42"}} { "data": { "approximate-count": null, "approximate-size": null, "auto-tiering": null, "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": { "operations": { "costcenter": "42" } }, "etag": "ea88f444-842c-462d-965e-d3540b3b54f6", "freeform-tags": {}, "id": "ocid1.bucket.oc1..exampleuniqueID", "is-read-only": false, "kms-key-id": null, "metadata": {}, "name": "MyBucketDefined", "namespace": "MyNamespace", "object-events-enabled": false, "object-lifecycle-policy-etag": null, "public-access-type": "NoPublicAccess", "replication-enabled": false, "storage-tier": "Standard", "time-created": "2020-06-23T19:47:51.362000+00:00", "versioning": "Disabled" }, "etag": "ea88f444-842c-462d-965e-d3540b3b54f6" }
The following example syntax creates a Standard tier bucket with a free-form tag:
oci os bucket create --namespace <object_storage_namespace> --name <bucket_name> --compartment-id <target_compartment_id> --freeform-tags <JSON_formatted_free-form_tag>
Examples of free-form tag formatting:
'{"Chicago_Team": "marketing_videos"}'
'{"Project": "prototype 3","Manager": "Meadows"}'
Note
If you are running the CLI on a Windows computer, you might need to use the backslash (\) character to escape the strings containing the tag values. For example, a single free-form tag is formatted as'{\"Chicago_Team\": {\"marketing_videos\"}}'
For example:
oci os bucket create --namespace MyNamespace --name MyBucketFreeform --compartment-id ocid.compartment.oc1..exampleuniqueID --freeform-tags {"Chicago_Team": "marketing_videos"} { "data": { "approximate-count": null, "approximate-size": null, "compartment-id": "ocid.compartment.oc1..exampleuniqueID", "created-by": "ocid1.user.oc1..exampleuniqueID", "defined-tags": {}, "etag": "6f4bda10-fc8b-462e-8563-875639fd7294", "freeform-tags": { "Chicago_Team": "marketing_videos" }, "is-read-only": false, "id": "ocid1.bucket.oc1..exampleuniqueID", "kms-key-id": null, "metadata": {}, "name": "MyBucketFreeform", "namespace": "MyNamespace", "object-events-enabled": false, "object-lifecycle-policy-etag": null, "public-access-type": "NoPublicAccess", "storage-tier": "Standard", "time-created": "2020-06-23T20:51:16.260000+00:00" }, "etag": "6f4bda10-fc8b-462e-8563-875639fd7294" }
For information about using the API and signing requests, see REST API documentation and Security Credentials. For information about SDKs, see SDKs and the CLI.
When accessing the Object Storage API, the bucket name is used with the Object Storage namespace name to form the request URL:
CreateBucketn/<object_storage_namespace>/b/<bucket>
Note
Two key properties are worthy of mention in the payload for CreateBucket and UpdateBucket APIs:
publicAccessType
property controls whether the bucket is private or public and limits the capability to list public bucket contents.objectEventsEnabled
property controls if events are emitted for the objects in this bucket.