Updated on 2024-04-01 GMT+08:00

Creating a Custom Bucket Policy (JSON View)

If you are familiar with the JSON syntax and OBS bucket policies, you can code a bucket policy in the JSON view. There is no limit on the number of bucket policies (statements) for a bucket, but the JSON descriptions of all bucket policies in a bucket cannot exceed 20 KB in total.

Procedure

  1. In the navigation pane of OBS Console, choose Object Storage.
  2. In the bucket list, click the bucket you want to operate to go to the Objects page.
  3. In the navigation pane, choose Permissions > Bucket Policies.
  4. In the upper right corner of the page, click JSON and then Edit.
  5. Edit the bucket policy. Below gives a bucket policy example in JSON:

    {
       "Statement":[
           {
               "Action":[
                   "CreateBucket",
                   "DeleteBucket"
               ],
               "Effect":"Allow",
               "Principal":{
                   "ID":[
                       "domain/account ID", 
                       "domain/account ID:user/User ID" 
                   ]
               },
               "Condition":{
                   "NumericNotEquals":{
                       "Referer":"sdf"
                   },
                   "StringNotLike":{
                       "Delimiter":"ouio"
                   }
               },
               "Resource":"000-02/key01"
           }
       ]
     }
    Table 1 Parameters for creating a bucket policy in JSON

    Parameter

    Description

    Action

    Actions the bucket policy applies to. For details, see Bucket Policy Parameters.

    Effect

    Effect of the bucket policy. For details, see Bucket Policy Parameters.

    Principal

    Users the bucket policy is applied to. You can obtain the user ID on the My Credentials page by logging in to the console as the user to be authorized. Principals should be configured as follows:

    • domain/Account ID (indicating that the principal is an account)
    • domain/Account ID:user/User ID (indicating that the principal is a user under an account)

    Condition

    Conditions under which the bucket policy takes effect. For details, see Bucket Policy Parameters.

    Resource

    Resources the bucket policy is applied to. For details, see Bucket Policy Parameters.

  6. Click Create.