Example 3: Using a Custom Bucket Policy to Grant Read/Write Permissions Required for Adding an External Bucket

A custom bucket policy can be used to grant the read and write access permissions to the bucket to be added.

If a custom bucket policy is used to authorize such permissions, the ListBucket, GetObject, and GetObjectVersion actions must be allowed. More actions can be allowed according to your actual needs.

Procedure

  1. Log in to OBS Console.

  2. In the bucket list, click the bucket you want to operate. The Overview page is displayed.

  3. In the navigation pane on the left, click Permissions to go to the permission management page.

  4. In the Custom Bucket Policies area, click Create Bucket Policy. The Create Bucket Policy dialog box is displayed.

  5. Configure the parameters listed in the table below to grant other accounts the bucket access permissions.

    Table 1 Parameters for granting permissions to access the bucket

    Parameter

    Value

    Policy Mode

    Customized

    Effect

    Allow

    Principal

    • Include

    • Other account: Enter an account ID. If you want to grant the permissions to all users, enter *.

    Note

    The account ID and user ID can be obtained on the My Credentials page of the account or user to be authorized. Account ID corresponds to Domain ID on the My Credentials page. If you grant the permission to only an account, you do not need to enter user IDs. If you want to grant the permission to IAM users of an account, you need to enter the account ID and user IDs. Multiple IAM user IDs should be separated with commas (,).

    Resources

    • Include

    • Leave it blank.

    Actions

    • Include

    • ListBucket

  6. Click OK.

  7. Create another bucket policy to grant the authorized account the permissions to access resources in the bucket. For details, see the table below.

    Table 2 Parameters for granting permissions to access resources in the bucket

    Parameter

    Value

    Policy Mode

    Customized

    Effect

    Allow

    Principal

    Keep the value consistent with the preceding policy.

    Resources

    • Include

    • Resource name: *

    Actions

    • Include

    • GetObject

    • GetObjectVersion

    • PutObject

    • DeleteObject

    • DeleteObjectVersion

  8. Click OK.

Verification

  1. Log in to OBS Browser.

  2. Click Add Bucket on the upper left corner of the page. The Add Bucket dialog box is displayed.

  3. Select Add external bucket and enter the bucket name.

  4. Click OK. The external bucket is added successfully.

  5. Click the newly added external bucket to open the bucket.

  6. Click Upload Object, and objects can be successfully uploaded to the bucket.

  7. Select an object in the bucket and click Delete. The object can be deleted successfully.