Skip to content

Instantly share code, notes, and snippets.

@akoumjian
Created July 6, 2021 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akoumjian/d44aeeb8ba91dc1765c79f04f34b1597 to your computer and use it in GitHub Desktop.
Save akoumjian/d44aeeb8ba91dc1765c79f04f34b1597 to your computer and use it in GitHub Desktop.
How to Tell if an S3 Object in Intelligent Tiering is in an Archive Status
import boto3
def s3_object_needs_restore(bucket, key):
s3_client = boto3.client("s3")
head_response = s3_client.head_object(Bucket=bucket, Key=key)
"""
The Head Response will include an `x-amz-archive-status` value if the object
is in INTELLIGENT_TIERING and is currently archived
"""
if "ArchiveStatus" in head_response:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment