--- title: "put-bucket-lifecycle-configuration" slug: "put-bucket-lifecycle-configuration" updated: 2026-10-08T09:47:40Z published: 2026-10-08T09:47:40Z canonical: "cli.ncloud-docs.com/put-bucket-lifecycle-configuration" --- > ## Documentation Index > Fetch the complete documentation index at: https://cli.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # put-bucket-lifecycle-configuration Classic/VPC環境で利用できます。 Ncloud Storageバケットにライフサイクルの新規ルールを登録したり、既存のライフサイクルルールを上書きしたりします。 参考 Sub Accountユーザーがこのコマンドを実行するには、Change/PutLifecycleConfigurationアクションの権限が必要です。 ## 構文 `put-bucket-lifecycle-configuration`構文は次の通りです。 ``` aws s3api put-bucket-lifecycle-configuration \ --bucket \ --lifecycle-configuration \ --endpoint-url ``` ## オプション `put-bucket-lifecycle-configuration`の実行時に指定できるオプションについて説明します。 ### 必須オプション `put-bucket-lifecycle-configuration`の必須オプションです。 | オプション | タイプ | 必須の有無 | 説明 | | --- | --- | --- | --- | | `--bucket` | String | Required | バケット名 | | `--lifecycle-configuration` | String | Required | ライフサイクルルール - [構文](/docs/ja/put-bucket-lifecycle-configuration#lifecycleconfiguration%EA%B5%AC%EB%AC%B8)を参照 | #### `--lifecycle-configuration`構文 - 例1: バケットのバージョニングが有効になっていない場合 - `Transition`ルールに従い、`documents/`接頭辞を持つオブジェクトを180日後に`DEEP_ARCHIVE`ストレージクラスへ移行します。 - `Expiration`ルールに従い、`logs/`接頭辞を持つオブジェクトを作成から360日後に削除します。 ``` { "Rules": [ { "ID": "tran_documents", "Filter": { "Prefix": "documents/" }, "Status": "Enabled", "Transitions": [ { "Days": 180, "StorageClass": "DEEP_ARCHIVE" } ] }, { "ID": "exp_logs", "Filter": { "Prefix": "logs/" }, "Status": "Enabled", "Expiration": { "Days": 360 } } ] } ``` - 例2: バケットのバージョニングが有効になっている場合 - `NoncurrentVersionTransition`ルールに従い、`documents/`接頭辞を持つオブジェクトのうち、最新5つの旧バージョンを除く残りのオブジェクトバージョンを、旧バージョンになってから180日経過後に自動で`DEEP_ARCHIVE`ストレージクラスへ移行します。 - `NoncurrentVersionExpiration` ルールに従い、`logs/`接頭辞を持つオブジェクトが非現行になってから100日経過後に削除します。 ``` { "Rules": [ { "ID": "tran_noncurrent_documents", "Filter": { "Prefix": "documents/" }, "Status": "Enabled", "NoncurrentVersionTransitions": [ { "NewerNoncurrentVersions": 5, "NoncurrentDays": 180, "StorageClass": "DEEP_ARCHIVE" } ] }, { "ID": "exp_noncurrent_logs", "Filter": { "Prefix": "logs/" }, "Status": "Enabled", "NoncurrentVersionExpiration": { "NoncurrentDays": 100 } } ] } ``` ### 共通オプション `aws`コマンドで共通して使用するオプションについては、[Ncloud Storageのオプション](/docs/ja/storage-ncloudstorage#%EC%98%B5%EC%85%98)をご参照ください。 ## 例 ライフサイクルルールの登録リクエストが成功すると、ルールが適用され、結果は出力されません。 ### コマンド コマンドの例は次の通りです。 ``` aws s3api put-bucket-lifecycle-configuration --bucket my-test-bucket \ --lifecycle-configuration file://lifecycle.json \ --endpoint-url=https://kr.ncloudstorage.com ``` ## 関連コマンド 関連コマンドは次の通りです。 - [delete-bucket-lifecycle](/docs/ja/delete-bucket-lifecycle) - [get-bucket-lifecycle-configuration](/docs/ja/get-bucket-lifecycle-configuration)