put-bucket-policy

Updated at:

The put-bucket-policy command configures a bucket policy for a specified vector bucket. This command grants one or more Resource Access Management (RAM) users or RAM roles that belong to your Alibaba Cloud account or other Alibaba Cloud accounts permission to access resources in the bucket.

Notes

An Alibaba Cloud account has the permission to set an authorization policy for a specified bucket by default. If you use a RAM user or Security Token Service (STS) to set the policy, you must have the oss:PutBucketPolicy permission. For more information, see Grant custom permissions to a RAM user.

Command format

ossutil api put-bucket-policy --bucket value --body value [flags]

Parameter

Type

Description

--bucket

string

The name of the bucket.

--body

string

The request body in JSON format. It defines the access permissions.

Note

The put-bucket-policy command corresponds to the PutBucketPolicy API operation.

--body

The --body option supports JSON syntax.

{
  "Version": "1",
  "Statement": [
    {
      "Action": ["oss:PutObject", "oss:GetObject"],
      "Effect": "Deny",
      "Principal": ["1234567890"],
      "Resource": ["acs:ossvector:cn-hangzhou:1234567890:*"]
    }
  ]
}
Note

Usage examples

The following example shows how to set a bucket policy using a JSON configuration file named vector-policy.json. The file contains the following content:

{
   "Version":"1",
   "Statement":[
       {
         "Action":[
           "oss:PutVectors",
           "oss:GetVectors"
        ],
        "Effect":"Deny",
        "Principal":["1234567890"],
        "Resource":["acs:ossvector:cn-hangzhou:1234567890:*"]
       }
    ]
}
ossutil vectors-api put-bucket-policy --bucket vector-example --body file://vector-policy.json

You can set a bucket policy for a vector bucket using a JSON configuration parameter:

ossutil vectors-api put-bucket-policy --bucket vector-example --body "{\"Version\":\"1\",\"Statement\":[{\"Action\":[\"oss:PutVectors\",\"oss:GetVectors\",\"oss:QueryVectors\"],\"Effect\":\"Allow\",\"Principal\":[\"1234567890\"],\"Resource\":[\"acs:ossvector:cn-hangzhou:1234567890:bucket/vector-example/*\"]}]}"