tencent cloud

Bucket Encryption Policy -bucket-encryption
Last updated: 2025-10-28 16:02:47
Bucket Encryption Policy -bucket-encryption
Last updated: 2025-10-28 16:02:47
The bucket-policy command is used to set, query, and delete bucket policy.
Note:
To query bucket policy, when performing authorization policy, set action to cos:GetBucketPolicy.
To set a bucket policy, when performing authorization policy, set action to cos:PutBucketPolicy.
Note: To delete bucket policy, when performing authorization policy, set action to cos:DeleteBucketPolicy.
For more authorization, please refer to business APIs that support CAM.

Command Syntax

./coscli bucket-policy --method [method] cos://<bucket-name>
The bucket-policy command includes the following parameters:
Parameter Format
Description
Example
cos://<bucket-name>
Specify the target bucket. It supports the use of the bucket alias or bucket name in configuration parameters. If you use the bucket name for access, you must carry the endpoint flag.
Access with the bucket alias: cos://example-alias
Access with the bucket name: cos://examplebucket-1250000000
The bucket-policy command includes the following optional flags:
Flag Abbreviation
Flag Name
Description
-h
--help
Views the usage of this command.
None
--method
Specify the operation to perform, including put (set bucket policy), get (query bucket policy), delete (delete bucket policy)
None
--policy
Bucket policy (JSON format or directly specify the file path, such as /data/policy.txt, which needs to be specified as file:///data/policy.txt)
Note:
For more general options for this command (such as switching buckets or user accounts), see Common Options.

Setting a Bucket Policy

Operation Example

Set the bucket policy for the bucket named example-alias. The command is as follows (see PUT Bucket policy):
./coscli bucket-policy --method put cos://example-alias --policy="{\\"Statement\\":[...]}"

Querying a Bucket Policy

Operation Example

Query the policy information for the bucket named example-alias.
./coscli bucket-policy --method get cos://example-alias
Output result, as shown below.
SECTION | KEY | VALUE
---------------+-----------+----------------------------------------------------------------
Policy | Version | 2.0
+--------------+-----------+---------------------------------------------------------------+
| |
+--------------+-----------+---------------------------------------------------------------+
Statement #1 | SID | costs-12331231231123123-80285-3
+ +-----------+---------------------------------------------------------------+
| Effect | allow
+ +-----------+---------------------------------------------------------------+
| Principal | qcs:
| | - qcs::cam::uin/1000000000:uin/1000000000
| | - qcs::cam::uin/1000000000:uin/1000000000
| |
+ +-----------+---------------------------------------------------------------+
| Action | name/cos:GetBucket
+ +-----------+---------------------------------------------------------------+
| Resource | qcs::cos:ap-nanjing:uid/1240000000:test-1240000000/*
+ +-----------+---------------------------------------------------------------+
| Condition | ip_equal:
| | qcs:ip:
| | - 11.9.10.8
| |
---------------+-----------+----------------------------------------------------------------
Bucket Policy Information

Deleting a Bucket Policy

Operation Example

Delete the bucket policy for the bucket named example-alias. The command is as follows:
./coscli bucket-policy --method delete cos://example-alias




Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback