I am using boto3 to successfully copy S3 objects to GLACIER_IR storage class with the following code:
copy_source = {'Bucket': obj['Bucket'], 'Key': obj['Key']}
s3.copy(CopySource=copy_source, Bucket=bucket, Key=filename_w_timestamp, StorageClass='GLACIER_IR')
However, when I use a very similar code to retrieve the above file back, I get the following error:
botocore.errorfactory.ObjectNotInActiveTierError: An error occurred (ObjectNotInActiveTierError) when calling the CopyObject operation: The source object of the COPY operation is not in the active tier and is only stored in Amazon Glacier.
Here is the piece of code I am using to attempt retrieval:
s3.copy(CopySource=copy_source, Bucket=bucket, Key=filename_w_timestamp)
Can someone please help out with what I am doing wrong here.
Thank you for the tip John Rotenstein. For future me and others, I change my code to following and now it works.
copy_source = {
'Bucket': obj['Bucket'],
'Key': obj['Key']
}
# Restore the object from Glacier Instant Retrieval tier
s3.restore_object(Bucket=obj['Bucket'], Key=obj['Key'], RestoreRequest={'Days': 1})
# Wait for the object to be restored (This may take some time)
waiter = s3.get_waiter('object_exists')
waiter.wait(Bucket=obj['Bucket'], Key=obj['Key'])
# Copy the object to the Standard tier bucket
s3.copy_object(Bucket=dest_bucket, CopySource=copy_source, Key=obj['Key'])