A bucket policy grants or restricts access to specific OSS resources for anonymous users or identified users — including Alibaba Cloud accounts, RAM users, and RAM roles. For example, you can grant read-only access to specific OSS resources to a RAM user in another Alibaba Cloud account.
This topic covers three operations:
Configure a bucket policy —
PutBucketPolicyGet the current bucket policy —
GetBucketPolicyDelete a bucket policy —
DeleteBucketPolicy
All examples use the cn-hangzhou region and a public endpoint. To access bucket resources from another Alibaba Cloud service in the same region, use an internal endpoint. For endpoint mappings, see Regions and endpoints.
Prerequisites
Before you begin, make sure you have:
Familiarity with bucket policies, including how to write policy statements and supported actions
AccessKey ID and AccessKey secret set as environment variables
The required permission for the operation you want to perform:
Operation Required permission Configure a bucket policy oss:PutBucketPolicyGet a bucket policy oss:GetBucketPolicyDelete a bucket policy oss:DeleteBucketPolicyFor more information, see Attach a custom policy to a RAM user.
What's next
Bucket policies — policy statement syntax, supported actions, and common examples
RAM user permissions for OSS — attach custom policies to RAM users