バケットのインベントリを設定します。
使用上の注意
バケットのインベントリを設定できるのは、
oss:PutBucketInventory
権限を持つバケット所有者とRAMユーザーだけです。インベントリを構成する前に、インベントリを構成するバケット内のすべてのオブジェクトにアクセスし、インベントリリストを格納するバケットにデータを書き込む権限があるRAMロールがあることを確認します。 初めてバケットインベントリ機能を使用する場合は、Object Storage Service (OSS) コンソールでインベントリを設定することを推奨します。 インベントリを設定すると、OSSリソースに対するすべての操作を実行する権限を持つRAMロールを取得できます。 インベントリの設定に必要なRAMロールの権限の詳細については、「バケットインベントリ」をご参照ください。
バケットには最大1,000のインベントリを設定できます。
インベントリリストを保存するバケットは、インベントリを設定するバケットと同じリージョンにある必要があります。
コマンド構文
ossutil api put-bucket-inventory --bucket value --inventory-id value --inventory-configuration value [flags]
パラメーター | データ型 | 説明 |
-- bucket | String | バケットの名前です。 |
-- inventory-configuration | String | インベントリの構成情報を格納するコンテナー。 |
-- inventory-id | String | インベントリのID。 |
put-bucket-inventoryコマンドは、PutBucketInventoryコマンドと同じです。 API操作の詳細については、「PutBucketInventory」をご参照ください。
-- inventory-configuration
-- inventory-configurationパラメーターは、XMLおよびJSON形式をサポートします。 操作の値が "file://" で始まる場合、設定は指定されたファイルから読み込まれます。
XML 形式:
<InventoryConfiguration> <Id>string</Id> <IsEnabled>boolean</IsEnabled> <Destination> <OSSBucketDestination> <Bucket>string</Bucket> <Prefix>string</Prefix> <Encryption> <SSE-OSS> </SSE-OSS> <SSE-KMS> <KeyId>string</KeyId> </SSE-KMS> </Encryption> <Format>string</Format> <AccountId>string</AccountId> <RoleArn>string</RoleArn> </OSSBucketDestination> </Destination> <Schedule> <Frequency>string</Frequency> </Schedule> <Filter> <Prefix>string</Prefix> </Filter> <IncludedObjectVersions>string</IncludedObjectVersions> <OptionalFields> <Field>string</Field> ... </OptionalFields> </InventoryConfiguration>
JSON 形式:
[ { "IsEnabled": boolean, "Destination": { "OSSBucketDestination": { "Format": "string", "AccountId": "string", "RoleArn": "string", "Bucket": "string", "Prefix": "string", "Encryption": { "SSE-OSS": { }, "SSE-KMS": { "KeyId": "string" } } } }, "Schedule": { "Frequency": "string" }, "Filter": { "Prefix": "string" }, "IncludedObjectVersions": "string", "OptionalFields": { "Field": [ "string", ... ] }, "Id": "string" }, ... ]
サポートされているグローバルコマンドラインオプションの詳細については、「コマンドラインオプション」をご参照ください。
例
examplebucket
という名前のバケットにreport1
という名前のインベントリを設定します。
XML構成ファイルの使用 (この例ではinventory-configuration.xml)
<?xml version="1.0" encoding="UTF-8"?> <InventoryConfiguration> <Id>report1</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>Pics/</Prefix> <LastModifyBeginTimeStamp>1637883649</LastModifyBeginTimeStamp> <LastModifyEndTimeStamp>1638347592</LastModifyEndTimeStamp> <LowerSizeBound>1024</LowerSizeBound> <UpperSizeBound>1048576</UpperSizeBound> <StorageClass>Standard,IA</StorageClass> </Filter> <Destination> <OSSBucketDestination> <Format>CSV</Format> <AccountId>100000000000000</AccountId> <RoleArn>acs:ram::100000000000000:role/AliyunOSSRole</RoleArn> <Bucket>acs:oss:::destbucket</Bucket> <Prefix>prefix1/</Prefix> <Encryption> <SSE-KMS> <KeyId>keyId</KeyId> </SSE-KMS> </Encryption> </OSSBucketDestination> </Destination> <Schedule> <Frequency>Daily</Frequency> </Schedule> <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields> <Field>Size</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>StorageClass</Field> <Field>IsMultipartUploaded</Field> <Field>EncryptionStatus</Field> </OptionalFields> </InventoryConfiguration>
サンプルコマンド:
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration file://inventory-configuration.xml
JSON設定ファイルの使用 (この例のinventory-configuration.json)
{ "Id": "report1", "IsEnabled": "true", "Filter": { "Prefix": "Pics/", "LastModifyBeginTimeStamp": "1637883649", "LastModifyEndTimeStamp": "1638347592", "LowerSizeBound": "1024", "UpperSizeBound": "1048576", "StorageClass": "Standard,IA" }, "Destination": { "OSSBucketDestination": { "Format": "CSV", "AccountId": "100000000000000", "RoleArn": "acs:ram::100000000000000:role/AliyunOSSRole", "Bucket": "acs:oss:::destbucket", "Prefix": "prefix1/", "Encryption": { "SSE-KMS": { "KeyId": "keyId" } } } }, "Schedule": { "Frequency": "Daily" }, "IncludedObjectVersions": "All", "OptionalFields": { "Field": [ "Size", "LastModifiedDate", "ETag", "StorageClass", "IsMultipartUploaded", "EncryptionStatus" ] } }
サンプルコマンド:
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration file://inventory-configuration.json
コマンドラインでJSONパラメーターを使用する
ossutil api put-bucket-inventory --bucket examplebucket --inventory-id report1 --inventory-configuration "{\"Id\":\"report1\",\"IsEnabled\":\"true\",\"Filter\":{\"Prefix\":\"Pics/\",\"LastModifyBeginTimeStamp\":\"1637883649\",\"LastModifyEndTimeStamp\":\"1638347592\",\"LowerSizeBound\":\"1024\",\"UpperSizeBound\":\"1048576\",\"StorageClass\":\"Standard,IA\"},\"Destination\":{\"OSSBucketDestination\":{\"Format\":\"CSV\",\"AccountId\":\"100000000000000\",\"RoleArn\":\"acs:ram::100000000000000:role/AliyunOSSRole\",\"Bucket\":\"acs:oss:::destbucket\",\"Prefix\":\"prefix1/\",\"Encryption\":{\"SSE-KMS\":{\"KeyId\":\"keyId\"}}}},\"Schedule\":{\"Frequency\":\"Daily\"},\"IncludedObjectVersions\":\"All\",\"OptionalFields\":{\"Field\":[\"Size\",\"LastModifiedDate\",\"ETag\",\"StorageClass\",\"IsMultipartUploaded\",\"EncryptionStatus\"]}}"