Enables notifications of specified events for an Amazon S3 bucket. Currently, the
s3:ReducedRedundancyLostObject
event is the only event supported for notifications. The
s3:ReducedRedundancyLostObject
event is triggered when Amazon S3 detects that it has lost all
copies of an Amazon S3 object and can no longer service requests for that object.
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.
By default, only the bucket owner can configure notifications on a bucket. However, bucket owners
can use bucket policies to grant permission to other users to set this configuration with the
s3:PutBucketNotification
permission.
After a PUT operation is called 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 the 200 OK responses with a
x-amz-sns-test-message-id
header containing the message ID of the test notification sent to topic.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The name of the bucket to create bucket notifications for. |
|
|
Required |
The SNS topic ARN to send notifications to. |
|
|
Required |
The event type to listen for. |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Create bucket notification.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); // Create an SNS topic $sns = new AmazonSNS(); $topic = $sns->create_topic('my-topic')->body->TopicArn()->first(); $response = $s3->create_bucket_notification($bucket, $topic, 's3:ReducedRedundancyLostObject'); // Success? var_dump($response->isOK());Result:
bool(true)
Related Methods
See Also
Source
Method defined in services/s3.class.php | Toggle source view (19 lines) | View on GitHub