このページは、ボールトと 2012 年リリース当時の REST API を使用する、Amazon Glacier サービスの既存のお客様のみを対象としています。
アーカイブストレージソリューションをお探しの場合は、Amazon S3 の Amazon Glacier ストレージクラス (S3 Glacier Instant Retrieval、S3 Glacier Flexible Retrieval、S3 Glacier Deep Archive) を使用することをお勧めします。これらのストレージオプションの詳細については、「Amazon Glacier ストレージクラス」を参照してください。
Amazon Glacier (元のスタンドアロンのボールトベースのサービス) は、2025 年 12 月 15 日以降、新規のお客様を受け入れなくなります。既存のお客様に影響はありません。Amazon Glacier は、ボールトにデータを保存する独自の API を備えたスタンドアロンサービスであり、Amazon S3 および Amazon S3 Glacier ストレージクラスとは異なります。既存のデータは Amazon Glacier で無期限に安全性が確保され、引き続きアクセス可能です。移行は必要ありません。低コストの長期アーカイブストレージをお探しの場合、AWS は Amazon S3 Glacier ストレージクラスを推奨します。このストレージクラスは、コストを抑えながら、S3 バケットベースの API、AWS リージョン全体での可用性、AWS サービス統合により、優れたカスタマーエクスペリエンスを提供します。拡張機能が必要な場合は、Amazon Glacier ボールトから Amazon S3 Glacier ストレージクラスにデータを転送するための AWS ソリューションガイダンスを使用して、Amazon S3 Glacier ストレージクラスへの移行を検討してください。
AWS SDK または CLI で SetVaultNotifications を使用する
次のサンプルコードは、SetVaultNotifications を使用する方法を説明しています。
アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。
- CLI
-
- AWS CLI
-
次のコマンドは、my-vault という名前のボールトの SNS 通知を設定します。
aws glacier set-vault-notifications --account-id - --vault-name my-vault --vault-notification-config file://notificationconfig.json
notificationconfig.json は、現在のフォルダにある JSON ファイルで、公開する SNS トピックとイベントを指定します。
{
"SNSTopic": "arn:aws:sns:us-west-2:0123456789012:my-vault",
"Events": ["ArchiveRetrievalCompleted", "InventoryRetrievalCompleted"]
}
Amazon Glacier では、オペレーションを実行する際にアカウント ID 引数が必要ですが、ハイフンを使用して使用中のアカウントを指定できます。
- Python
-
- SDK for Python (Boto3)
-
GitHub には、その他のリソースもあります。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。
class GlacierWrapper:
"""Encapsulates Amazon S3 Glacier API operations."""
def __init__(self, glacier_resource):
"""
:param glacier_resource: A Boto3 Amazon S3 Glacier resource.
"""
self.glacier_resource = glacier_resource
def set_notifications(self, vault, sns_topic_arn):
"""
Sets an Amazon Simple Notification Service (Amazon SNS) topic as a target
for notifications. Amazon S3 Glacier publishes messages to this topic for
the configured list of events.
:param vault: The vault to set up to publish notifications.
:param sns_topic_arn: The Amazon Resource Name (ARN) of the topic that
receives notifications.
:return: Data about the new notification configuration.
"""
try:
notification = self.glacier_resource.Notification("-", vault.name)
notification.set(
vaultNotificationConfig={
"SNSTopic": sns_topic_arn,
"Events": [
"ArchiveRetrievalCompleted",
"InventoryRetrievalCompleted",
],
}
)
logger.info(
"Notifications will be sent to %s for events %s from %s.",
notification.sns_topic,
notification.events,
notification.vault_name,
)
except ClientError:
logger.exception(
"Couldn't set notifications to %s on %s.", sns_topic_arn, vault.name
)
raise
else:
return notification
AWS SDK デベロッパーガイドとコード例の詳細なリストについては、「AWS SDK での Amazon Glacier の使用」を参照してください。このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。