Managing permissions bucket by bucket is tedious when you run many OSS buckets with shared access requirements. A resource group lets you group buckets that need the same permissions and authorize all of them at once.
When to use a resource group
Use a resource group when you manage multiple buckets under a single Alibaba Cloud account and need to apply the same permissions to a subset of those buckets without repeating configuration for each one.
For example, if your company stores test data in 20 buckets and you want all employees to have read-only access to 10 buckets and read-write access to the other 10, assign the first 10 to one resource group and the second 10 to another. Grant permissions once per group rather than once per bucket.
When a resource group is not the right fit:
You have only one or two buckets — grant permissions directly at the bucket level instead.
You need to grant access across multiple Alibaba Cloud accounts — resource groups operate within a single account.
Limits
| Limit | Detail |
|---|---|
| Bucket membership | A bucket can belong to only one resource group |
| Cross-region | A resource group can contain buckets from different regions |
| Cross-account transfers | Buckets can only be moved between resource groups owned by the same Alibaba Cloud account |
Prerequisites
Before you begin, make sure you have:
An Alibaba Cloud account with OSS buckets already created
Access to the RAM console and the Resource Management console
RAM (Resource Access Management) users added to your account (required for the console workflow)
Grant permissions by using the OSS console
This procedure uses the 20-bucket scenario described above. The goal is to grant all employees (RAM users) read-only access to ResourcegroupA (10 buckets) and read-write access to ResourcegroupB (10 buckets). A RAM user group, UserGroup1, applies the same permissions to all employees at once.
Step 1: Create a user group and add RAM users
Log on to the RAM console.
Create a user group named UserGroup1. For details, see Create a RAM user group.
Add all RAM users who need bucket access to UserGroup1. For details, see Add a RAM user to a RAM user group.
Step 2: Create resource groups
Log on to the Resource Management console.
In the left navigation pane, choose Resource Group > Resource Group.
On the Resource Group page, click Create Resource Group.
In the Create Resource Group panel, set Resource Group Name to
ResourcegroupAand Resource Group Identifier toGroup1.Click OK. The status shows Creating. After about 3 seconds, click the
icon to refresh. When the status changes to Available, the group is ready.Repeat these steps to create ResourcegroupB.
Step 3: Assign buckets to resource groups
Log on to the OSS console.
Click Buckets, then click the bucket you want to assign (for example, examplebucket1).
Choose Bucket Settings > Resource Group.
On the Resource Group page, click Settings.
Select ResourcegroupA from the Resource Group dropdown and click Save.
Repeat for each bucket: assign the 10 read-only buckets to ResourcegroupA and the 10 read-write buckets to ResourcegroupB.
Step 4: Grant permissions to resource groups
Log on to the Resource Management console. In the left navigation pane, choose Resource Group > Resource Group.
Find ResourcegroupA in the list and click Manage Permission in the Actions column.
On the Permissions tab, click Grant Permission.
In the Grant Permission panel, configure the following parameters:
Parameter Value Authorized scope Select Specific Resource Group, then select ResourcegroupA Principal Enter UserGroup1Select policy Select System Policy, then click AliyunOSSReadOnlyAccessClick OK, then click Complete.
Repeat these steps for ResourcegroupB, but select the
AliyunOSSFullAccesspolicy instead.
All RAM users in UserGroup1 now have read-only access to buckets in ResourcegroupA and read-write access to buckets in ResourcegroupB.
Assign a bucket to a resource group by using an SDK or CLI
Resource group configuration is supported in the OSS SDKs for Java, Python, and Go. All examples use the PutBucketResourceGroup operation and load credentials from the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables.
For an SDK overview, see Overview.
Python
Java
Go
Use ossutil
API reference
All methods above call the PutBucketResourceGroup API operation. To call it directly, include signature calculation in your code. For details, see PutBucketResourceGroup.