Set Amazon S3 Glacier vault notifications using an Amazon SDK - Amazon S3 Glacier
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Set Amazon S3 Glacier vault notifications using an Amazon SDK

The following code example shows how to set Amazon S3 Glacier vault notifications.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

SDK for Python (Boto3)

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

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("-", notification.set( vaultNotificationConfig={ "SNSTopic": sns_topic_arn, "Events": [ "ArchiveRetrievalCompleted", "InventoryRetrievalCompleted", ], } ) "Notifications will be sent to %s for events %s from %s.", notification.sns_topic,, notification.vault_name, ) except ClientError: logger.exception( "Couldn't set notifications to %s on %s.", sns_topic_arn, ) raise else: return notification

For a complete list of Amazon SDK developer guides and code examples, see Using S3 Glacier with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.