1

I have an s3 buckets with a bucket policy to send their objects to glacier after x days of creation. It is working fine by moving the objects to glacier storage.When I go to retrieve those objects later using aws php sdk 3.x api

$result = $client->restoreObject([
'Bucket' => '<string>', // REQUIRED
'Key' => '<string>', // REQUIRED
'RequestPayer' => 'requester',
'RestoreRequest' => [
    'Days' => <integer>, // REQUIRED
    'GlacierJobParameters' => [
        'Tier' => 'Standard|Bulk|Expedited', // REQUIRED
    ],
],
'VersionId' => '<string>', ])

Normally it may take 3-5 hours to restore the object. So I need to get a sns notification for that. As I am not using the vault for that I am not getting any notification after restored the object. How do I get sns notification after restore completion.

Senchu Thomas
  • 518
  • 3
  • 9
  • 24

2 Answers2

1

S3 event notification now support s3:ObjectRestore:Completed. See details in AWS documentation. You can configure SNS to send you notification upon Glacier restoration completed.

coppaste
  • 166
  • 1
  • 3
0

We will not get sns for the restore completion for that we need to poll using head object api

 $result = $s3Client->headObject(array(
        'Bucket' => $sourceBucket,
        'Key' => "{$archiveKey}/{$sourceKeyname}",
    ));

and compare the head object requests result

 if (isset($res['ongoing-request']) && (strcmp($res['ongoing-request'], '"false"') == 0) && ($result['StorageClass'] == 'GLACIER')) {
      $this->log('Survey data id  ' . $surveyData['survey_data_id'] . ' in restored state', LogLevel::INFO);}

and if the condition is true we can raise the action

Senchu Thomas
  • 518
  • 3
  • 9
  • 24