Granting Access Permissions on Buckets and Bucket Resources to IAM Users under Other Accounts

Scenario

This case describes how to grant IAM users under other HUAWEI CLOUD accounts the permissions to access OBS buckets and resources in the buckets.

The following describes how to grant the permissions to upload and download objects in a bucket. If you need to configure other specified permissions, configure the corresponding permissions in the bucket policy and IAM permissions.

Recommended Configuration

To grant permissions to IAM users under other accounts, you need to configure both bucket policies and IAM permissions.

For example, to allow IAM user A of account A to access bucket B of account B, you need to:

  1. Configure a bucket policy that allows IAM user A to access bucket B.
  2. Configure IAM permissions for account A to allow IAM user A to access bucket B.

The permissions allowed by both bucket policies and IAM permissions take effect.

Configuration Precautions

After the configuration is complete, the authorized IAM user can upload and download objects through APIs or SDKs. In addition, the user can upload and download objects by mounting external buckets on OBS Browser+. However, the ListBucket permission needs to be configured to ensure successful mounting. You cannot access buckets of other accounts on OBS Console.

Configuration Procedure 1: Configure a Bucket Policy That Allows Specified Operations

The bucket owner or a user who has the permission to configure bucket policies needs to configure a bucket policy that allows specified operations.

  1. In the navigation pane of OBS Console, choose Buckets.
  2. In the bucket list, click the bucket name you want to go to the Overview page.
  3. In the navigation pane, choose Permissions > Bucket Policy.
  4. On the Bucket Policies page, click Create.
  5. Locate the row containing Custom policy and click Create Custom Policy.
  6. Configure parameters for a bucket policy.

    Figure 1 Configuring bucket policy parameters
    Table 1 Parameter description

    Parameter

    Description

    Policy View

    Set this parameter based on your own habits. Example: Visual editor.

    Policy Name

    Name of the custom policy

    Policy Content

    • Select Allow.
    • Set Principal to Other account.
      • Account ID: Enter the ID of the account to which you want to grant permissions. The ID can be obtained from the My Credentials page of the account or the IAM user.
      • User ID: Enter the ID of the IAM user under the authorized account. You can obtain the ID on the My Credentials page of the IAM user. The wildcard character (*) is supported, indicating that the setting takes effect for all IAM users under the account.
      • User Policy: Select Include specified users.
    • Parameters under Resources:
      • Resource: Select both Current bucket and Object in bucket.
      • Object in bucket: Select Specified objects.

        For one object, enter object name.

        For a set of objects, enter object name prefix + *, * + object name suffix, or *.

      • Resource Policy: Select Include specified resources.
    • Parameters under Actions:
      • GetObject
      • GetObjectVersion
      • PutObject
      • (Optional) ListBucket: Select this operation if you need to use OBS Browser+ to add external buckets.

      To configure other specified operation permissions on objects, select the corresponding actions. For details about the actions supported by OBS, see Action/NotAction.

      • Operation Strategy: Select Include selected.

  7. After configuring the required parameters, click Next.
  8. Ensure all the configurations are correct and click Create.

Configuration Procedure 2: Configure an IAM Permission That Allows Specified Operations

The account to which the authorized IAM user belongs needs to configure the IAM permission for the IAM user to perform specified operations on the specified bucket. The allowed operations must be the same as those specified in the bucket policy.

  1. Log in to HUAWEI CLOUD using the account of the authorized IAM user and click Console in the upper right corner.
  2. On the console, hover your cursor over the username in the upper right corner, and choose Identity and Access Management from the drop-down list.
  3. In the navigation pane, choose Permissions > Policies/Roles > Create Custom Policy.
  4. Configure parameters for a custom policy.

    Figure 2 Configuring a custom policy
    Table 2 Parameters for configuring a custom policy

    Parameter

    Description

    Policy Name

    Name of the custom policy

    Policy View

    Set this parameter based on your own habits. Example: Visual editor.

    Policy Content

    • Select Allow.
    • Select Object Storage Service (OBS).
    • Select the actions to be authorized.
      • ReadOnly > obs:bucket:ListBucketVersions and obs:object:GetObjectVersion
      • ReadWrite > obs:object:PutObject
      • ListOnly > obs:bucket:ListBucket (Select this operation if you need to use OBS Browser+ to add external buckets.)

      If you need to configure other specified operation permissions, select the corresponding operations. For details about the operations, see Bucket-Related Actions and Object-Related Actions.

    • Choose Specific > object to specify an object resource. The specified object or object set must be consistent with the bucket policy.
      • Select Any if the resource set in the bucket policy is *.
      • If the resource specified in the bucket policy is a specified object or a set of objects, you need to specify the object or the set of objects the same as that in the bucket policy through the resource path.

        [Format]

        obs:*:*:object:bucket name/object name

      Select Any as the bucket policy in this example is set to * .

    • Choose Specific > bucket > Specify resource path to specify bucket resources.

      Click Add Resource Path and enter the name of the authorized bucket in the Path text box, for example, example-bucket.

      The complete path of the resource is as follows: OBS:*:*:bucket:example-bucket.

    Scope

    The default value is Global services.

  5. Click OK. The custom policy is created.
  6. Create a user group and assign permissions.

    Add the created custom policy to the user group by following the instructions in the IAM document.

  7. Add the IAM user to be authorized to the user group created by referring to Adding Users to or Removing Users from a User Group. The authorization is complete.

    Due to data caching, it takes about 10 to 15 minutes for a custom policy to take effect after the authorization.