AWS
S3InvalidObjectState - S3 Invalid Object State
Hitting an **S3InvalidObjectState** error means you're trying to access an S3 object that's archived in Glacier or Deep Archive storage class without restoring it first—archived objects must be restored before they can be accessed. This client-side error (4xx) happens when AWS validates object accessibility. Most common when accessing Glacier objects without restore, but also appears when objects are in Deep Archive, restoration hasn't completed, objects are archived and not restored, or accessing archived objects directly.
#Common Causes
- →Identity: IAM policy allows access but object archived. Service Control Policy (SCP) enforces storage class restrictions.
- →Network: VPC endpoint storage class restrictions. Object in archived state.
- →Limits: Object in Glacier storage class. Object in Deep Archive storage class. Object restoration not completed. Object archived and not restored.
✓Solutions
- 1Step 1: Diagnose - Check object storage class: aws s3api head-object --bucket BUCKET_NAME --key OBJECT_KEY --query 'StorageClass' --output text. Verify if object is in Glacier or Deep Archive.
- 2Step 2: Diagnose - Check restoration status: aws s3api head-object --bucket BUCKET_NAME --key OBJECT_KEY --query 'Restore' --output text. Check if restoration is in progress or completed.
- 3Step 3: Diagnose - Review object metadata: aws s3api head-object --bucket BUCKET_NAME --key OBJECT_KEY. Check StorageClass, Restore status, and ArchiveStatus.
- 4Step 4: Fix - Initiate restore request: For Glacier: aws s3api restore-object --bucket BUCKET_NAME --key OBJECT_KEY --restore-request '{"Days":7,"GlacierJobParameters":{"Tier":"Expedited"}}'. For Deep Archive, use appropriate tier.
- 5Step 5: Fix - Wait for restoration: Check restoration status periodically. Expedited: 1-5 minutes. Standard: 3-5 hours. Bulk: 5-12 hours. Once restored, object is accessible for specified days.
</>Code Examples
Check Object Storage Class and Restoration Status
1#!/bin/bash
2BUCKET_NAME="my-bucket"
3OBJECT_KEY="archived-file.zip"
4
5echo "=== Checking Object Storage Class ==="
6STORAGE_CLASS=$(aws s3api head-object \
7 --bucket ${BUCKET_NAME} \
8 --key ${OBJECT_KEY} \
9 --query 'StorageClass' \
10 --output text 2>/dev/null)
11
12if [ "${STORAGE_CLASS}" = "GLACIER" ] || [ "${STORAGE_CLASS}" = "DEEP_ARCHIVE" ]; then
13 echo "✗ Object is archived: ${STORAGE_CLASS}"
14 echo "Object must be restored before access"
15else
16 echo "✓ Object storage class: ${STORAGE_CLASS}"
17 echo "Object is accessible"
18fi
19
20echo "\n=== Checking Restoration Status ==="
21RESTORE_STATUS=$(aws s3api head-object \
22 --bucket ${BUCKET_NAME} \
23 --key ${OBJECT_KEY} \
24 --query 'Restore' \
25 --output text 2>/dev/null)
26
27if [ "${RESTORE_STATUS}" = "None" ] || [ -z "${RESTORE_STATUS}" ]; then
28 echo "✗ Object not restored"
29 echo "Initiate restore request"
30elif [[ "${RESTORE_STATUS}" == *"ongoing-request"* ]]; then
31 echo "⏳ Restoration in progress"
32elif [[ "${RESTORE_STATUS}" == *"expiry-date"* ]]; then
33 echo "✓ Object restored and accessible"
34 echo "Restore status: ${RESTORE_STATUS}"
35fiInitiate S3 Object Restoration from Glacier
1#!/bin/bash
2BUCKET_NAME="my-bucket"
3OBJECT_KEY="archived-file.zip"
4
5echo "=== Initiating Glacier Restoration ==="
6
7# Expedited restoration (1-5 minutes, most expensive)
8echo "Option 1: Expedited (1-5 minutes)"
9aws s3api restore-object \
10 --bucket ${BUCKET_NAME} \
11 --key ${OBJECT_KEY} \
12 --restore-request '{"Days":7,"GlacierJobParameters":{"Tier":"Expedited"}}' 2>&1
13
14# Standard restoration (3-5 hours)
15echo "\nOption 2: Standard (3-5 hours)"
16# aws s3api restore-object \
17# --bucket ${BUCKET_NAME} \
18# --key ${OBJECT_KEY} \
19# --restore-request '{"Days":7,"GlacierJobParameters":{"Tier":"Standard"}}'
20
21# Bulk restoration (5-12 hours, cheapest)
22echo "\nOption 3: Bulk (5-12 hours)"
23# aws s3api restore-object \
24# --bucket ${BUCKET_NAME} \
25# --key ${OBJECT_KEY} \
26# --restore-request '{"Days":7,"GlacierJobParameters":{"Tier":"Bulk"}}'
27
28echo "\n=== Checking Restoration Status ==="
29sleep 10 # Wait a moment
30aws s3api head-object \
31 --bucket ${BUCKET_NAME} \
32 --key ${OBJECT_KEY} \
33 --query 'Restore' \
34 --output textRestore Deep Archive Objects
1#!/bin/bash
2BUCKET_NAME="my-bucket"
3OBJECT_KEY="deep-archive-file.zip"
4
5echo "=== Restoring Deep Archive Object ==="
6
7# Deep Archive restoration (12 hours)
8aws s3api restore-object \
9 --bucket ${BUCKET_NAME} \
10 --key ${OBJECT_KEY} \
11 --restore-request '{"Days":7,"GlacierJobParameters":{"Tier":"Standard"}}'
12
13echo "\n=== Deep Archive Restoration Times ==="
14echo "Standard: 12 hours"
15echo "Bulk: 48 hours"
16echo "Expedited: Not available for Deep Archive"
17
18echo "\n=== Monitor Restoration ==="
19echo "Check status with:"
20echo "aws s3api head-object --bucket ${BUCKET_NAME} --key ${OBJECT_KEY} --query 'Restore'"
21
22echo "\n=== Once Restored ==="
23echo "Object will be accessible for the specified number of days"
24echo "After expiry, object returns to archived state"↗Related Errors
Provider Information
This error code is specific to AWS services. For more information, refer to the official AWS documentation.