S3のストレージクラスの変更
ストレージクラスの変更
AWS CLIコマンドから、ストレージクラスを変更する場合は、次のようにする。
Command:
$ aws s3 cp \ s3://YOUR-BUCKET/ \ s3://YOUR-BUCKET/ \ --recursive \ --storage-class <string>
<string>
の値は以下の通り。
value | 名前 |
---|---|
STANDARD | スタンダード(デフォルト) |
REDUCED_REDUNDANCY | |
STANDARD_IA | スタンダード IA (Infrequent Access) |
ONEZONE_IA | 1ゾーンIA |
INTELLIGENT_TIERING | |
GLACIER | |
DEEP_ARCHIVE | |
GLACIER_IR |
但し、ストレージクラスの変更には別途料金がかかる為、注意が必要。東京リージョンの場合1000件あたり0.03426USDかかる。
この為、大量のログをS3に格納している際には注意が必要と言える。まずは、過去のログをローカルの別の場所に保管して、S3を軽くする方を検討してみる方が良いかも。
検証
上記の方法で、ファイルのストレージクラスが変更されるかどうか実際に検証してみた。
$ aws s3 mb s3://mybucket-test94/ $ echo 'Hello World!' > hello.txt $ cat hello.txt Hello World! $ aws s3 cp ./hello.txt s3://mybucket-test94/ upload: ./hello.txt to s3://mybucket-test94/hello.txt $ aws s3 ls s3://mybucket-test94/ 2023-09-15 11:53:22 13 hello.txt $ aws s3api head-object --bucket mybucket-test94 --key hello.txt { "AcceptRanges": "bytes", "LastModified": "2023-09-15T02:53:22+00:00", "ContentLength": 13, "ETag": "\"8ddd8be4b179a529afa5f2ffae4b9858\"", "ContentType": "text/plain", "ServerSideEncryption": "AES256", "Metadata": {} } $ aws s3 cp s3://mybucket-test94/ s3://mybucket-test94/ --recursive --storage-class STANDARD_IA copy: s3://mybucket-test94/hello.txt to s3://mybucket-test94/hello.txt $ aws s3 ls s3://mybucket-test94/ 2023-09-15 11:59:02 13 hello.txt $ aws s3api head-object --bucket mybucket-test94 --key hello.txt { "AcceptRanges": "bytes", "LastModified": "2023-09-15T02:59:02+00:00", "ContentLength": 13, "ETag": "\"8ddd8be4b179a529afa5f2ffae4b9858\"", "ContentType": "text/plain", "ServerSideEncryption": "AES256", "Metadata": {}, "StorageClass": "STANDARD_IA" }
因みに、mv
じゃなくて、cp
なんじゃないかと思ってmv
で試してみたがエラーとなった。ストレージクラスの変更では、上記のようにaws s3 cp
コマンドを用いることに注意する。
$ aws s3 mv s3://mybucket-test94/ s3://mybucket-test94/ --recursive --storage-class STANDARD Cannot mv a file onto itself: 's3://mybucket-test94/' - 's3://mybucket-test94/'
ストレージクラスの料金
以下は目安:
ストレージクラス | 料金 | 比較 |
---|---|---|
S3 Standard | 0.0250 USD/GB | 100 |
S3 Intelligent-Tiering | 0.0250 USD/GB ※ | 100 |
S3 Standard-IA | 0.0138 USD/GB | 55 |
S3 One Zone IA | 0.0110 USD/GB | 44 |
S3 Glacier Instant Retrieval | 0.0050 USD/GB | 20 |
S3 Glacier Flexible Retrieval | 0.0045 USD/GB | 18 |
S3 Glacier Deep Archive | 0.0020 USD/GB | 8 |
※ モニタリング及びオートメーション費用が別途かかる。
参考: