Updated on 2024-04-16 GMT+08:00

Limiting the Time When Objects in a Bucket Are Accessible

You can configure the bucket policy to limit the time when objects in a bucket are accessible. In the following example, the access time window is from 2019-03-26T12:00:00Z to 2019-03-26T15:00:00Z.

Procedure

  1. In the bucket list, click the bucket you want to operate to go to the Objects page.
  2. In the navigation pane, choose Permissions > Bucket Policies.
  3. Click Create.
  4. Configure parameters listed in the table below.

    Table 1 Limiting the time when objects in a bucket are accessible

    Parameter

    Description

    Configuration method

    Choose Visual Editor.

    Policy Name

    Enter a custom policy name.

    Policy content

    Effect

    Select Allow.

    Principals

    • Select All accounts.

    Resources

    • Select Specified objects.
    • Set the resource path to *.
      NOTE:
      1. * indicates all objects in a bucket.
      2. This example only grants permissions for resources in the bucket. If you also want to grant permission for the bucket (for example, the permission to list objects in the bucket), create another custom bucket policy.

    Actions

    • Choose Customize.
    • Select * (indicating all object actions).
    NOTE:

    Selecting * may cause resources to be deleted. To avoid this risk, select Get* that indicates all read permissions.

    Conditions

    • Condition 1:
      • Key: Select CurrentTime.
      • Condition Operator: Select DateGreaterThan.
      • Value: Enter 2019-03-26T12:00:00Z (UTC).
    • Condition 2:
      • Key: Select CurrentTime.
      • Condition Operator: Select DateLessThan.
      • Value: Enter 2019-03-26T15:00:00Z (UTC).

  5. Click Create in the lower right corner.

Verification

During the specified time period, any user can access the specified resources in the bucket. Outside the specified time period, only the bucket owner can access the bucket.