Enables or disables access tracking for a bucket.
Prerequisites
Before you begin, ensure that you have:
An OSS bucket
The
oss:PutBucketAccessMonitorpermission (required for RAM users and Security Token Service (STS) identities; an Alibaba Cloud account has this permission by default)
To grant the permission to a RAM user, see Attach a custom policy to a RAM user.
Syntax
ossutil api put-bucket-access-monitor --bucket <value> --access-monitor-configuration <value> [flags]Required parameters
| Parameter | Type | Description |
|---|---|---|
--bucket | string | The name of the bucket. |
--access-monitor-configuration | string | The access tracking configuration for the bucket. Accepts XML or JSON format, inline or from a file. |
For supported global flags, see Global command-line options.
This command corresponds to the PutBucketAccessMonitor API operation. For the full parameter reference, see the API documentation.
--access-monitor-configuration format
The --access-monitor-configuration flag accepts XML or JSON. To read the configuration from a file, prefix the file path with file://.
XML:
<AccessMonitorConfiguration>
<Status>string</Status>
</AccessMonitorConfiguration>JSON:
{
"Status": "string"
}Examples
The following examples enable access tracking for a bucket named examplebucket.
Option 1: Use an XML configuration file
Create access-monitor-configuration.xml:
<?xml version="1.0" encoding="UTF-8"?>
<AccessMonitorConfiguration>
<Status>Enabled</Status>
</AccessMonitorConfiguration>Run:
ossutil api put-bucket-access-monitor --bucket examplebucket --access-monitor-configuration file://access-monitor-configuration.xmlOption 2: Use a JSON configuration file
Create access-monitor-configuration.json:
{
"Status": "Enabled"
}Run:
ossutil api put-bucket-access-monitor --bucket examplebucket --access-monitor-configuration file://access-monitor-configuration.jsonOption 3: Pass inline JSON
ossutil api put-bucket-access-monitor --bucket examplebucket --access-monitor-configuration "{\"Status\":\"Enabled\"}"