| Did this page help you? Yes No Tell us about it... |
The Amazon S3 notifications feature enables you to configure a bucket so that Amazon S3 publishes a message to an Amazon Simple Notification Service (SNS) topic when Amazon S3 detects a key event on a bucket. Subscribers to this topic can have messages for bucket events delivered to an endpoint such as a web server, e-mail address, or an Amazon Simple Queue Service queue.
Note that Notification fees will be charged at the normal Amazon SNS rates. For details about pricing, go to http://aws.amazon.com/sns/#pricing. There are no additional Amazon S3 charges for publishing a message to an Amazon SNS topic beyond the request fee to enable and disable the feature. In order to receive notifications of a bucket's events, you must subscribe to the topic that has been configured for that bucket.
Currently, the s3:ReducedRedundancyLostObject event is the only
event supported by Amazon S3. The s3:ReducedRedundancyLostObject event is
triggered when Amazon S3 detects that it has lost all replicas of a Reduced Redundancy Storage (RRS) object and can no longer
service requests for that object. Notification on this event can enable you to replace
missing RRS objects proactively to ensure there is no customer impact.
Notifications are published to a specified Amazon SNS topic. Currently, only one topic can be configured for notifications. If the bucket owner and Amazon SNS topic owner are the same, the bucket owner has permission to publish notifications to the topic by default. Otherwise, the owner of the topic must create a policy to enable the bucket owner to publish to the topic. For more information about creating this policy, see Example Cases for Amazon SNS Access Control.
![]() | Important |
|---|---|
| The Amazon SNS topic specified for a bucket’s notification configuration must be in the same region as the bucket. |
The following table lists the topic regions for the possible
LocationContraint values for buckets.
| LocationConstraint | Topic Region |
|---|---|
| Empty string | us-east-1 |
| EU | eu-west-1 |
| us-west-1 | us-west-1 |
| us-west-2 | us-west-2 |
| ap-northeast-1 | ap-northeast-1 |
| ap-southeast-1 | ap-southeast-1 |
| sa-east-1 | sa-east-1 |
By default, only the bucket owner has permission to set and view the notifications on
a bucket. However, the bucket owner can use a bucket policy to grant permission to other
users to set this configuration using the s3:PutBucketNotification
permission or view this configuration via the
s3:GetBucketNotification permission. For more information about
bucket policy, see Using Bucket Policies.
Similar to other bucket settings, there is a sub-resource for each bucket enabling you
to set or view that bucket's notification settings. To configure notifications on a bucket,
use the bucket’s notification sub-resource with the Amazon S3 REST API. For more information
about the notification sub-resource, see Put Bucket notification and Get Bucket notification.
To set notifications for a bucket
Use the PUT operation with a request body containing a
NotificationConfiguration element that specifies the
Amazon Resource Name (ARN) of the Amazon SNS topic, where the notification will be
published, and what events will be reported.
PUT ?notification HTTP/1.1
Host: quotes.s3.amazonaws.com
Date: Wed, 02 June 2010 12:00:00 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:xQE0diMbLRepdf3YB+FIEXAMPLE=
<NotificationConfiguration>
<TopicConfiguration>
<Topic>arn:aws:sns:us-east-1:111122223333:myTopic</Topic>
<Event>s3:ReducedRedundancyLostObject</Event>
</TopicConfiguration>
</NotificationConfiguration>
After you call the PUT operation to configure notifications on a
bucket, Amazon S3 publishes a test notification to ensure that the topic exists and that the
bucket owner has permission to publish to the specified topic. If the notification is
successfully published to the SNS topic, the PUT operation updates the
bucket configuration and returns a 200 OK response with a
x-amz-sns-test-message-id header containing the message ID of the
test notification sent to the topic. For information about PUT
operation errors, see Put Bucket
notification.
The message published for an event to a topic contains the fields listed in the following table.
| Name | Description |
|---|---|
| Service | Amazon S3. |
| Event | Currently, the only supported event is
s3:ReducedRedundancyLostObject. |
| Time | The time that the event was triggered. |
| Bucket | The name of the bucket. |
| Key | The object name. |
| VersionId | If versioning is enabled, the version ID. If versioning is not enabled, empty string. |
| RequestID | A unique ID that identifies which Amazon S3 operation published the notification. |
| HostID | A unique ID that identifies which host sent the message. |
The following message is an example of a message publishing an
s3:ReducedRedundancyLostObject event:
{
"Service":"Amazon S3",
"Event": "s3:ReducedRedundancyLostObject",
"Time":"2010-02-11T23:48:22.000Z",
"Bucket": "myphotos",
"Key": "Home/2009/10/carvingpumpkins.jpg",
"VersionId":"qfXHy5689N7n9mWVwanN_hIroMn_rzXl",
"RequestId":"4442587FB7D0A2F9",
"HostId":"fHZOHz+oQlKAFQ7RgVSklvcDNYI0v05gsOWWeJcyTTXWgGzI6CC5FZVICjD9bUzT"
}
The following message is an example of the test message that Amazon S3 sends when a bucket is enabled for notifications:
{
"Service":"Amazon S3",
"Event": "s3:TestEvent",
"Time":"2010-02-11T23:48:22.000Z",
"Bucket": "myphotos",
"RequestId":"4442587FB7D0A2F9",
"HostId":"fHZOHz+oQlKAFQ7RgVSklvcDNYI0v05gsOWWeJcyTTXWgGzI6CC5FZVICjD9bUzT"
}
To read the notification configuration for a bucket
Use the GET operation, which returns a
NotificationConfiguration element containing the Amazon
SNS topic and events set for notification on the bucket.
GET ?notification HTTP/1.1 Host: quotes.s3.amazonaws.com Date: Wed, 09 June 2010 12:00:00 GMT Authorization: AWS AKIAIOSFODNN7EXAMPLE:xQE0diMbLRepdf3YB+FIEXAMPLE=
To turn off notifications on a bucket
Use the PUT operation with
a request body containing an empty NotificationConfiguration
element.