AWS
S3InvalidStorageClass - S3 Invalid Storage Class
Hitting an **S3InvalidStorageClass** error means the S3 storage class you specified is invalid or not supported for the operation—the storage class name might be misspelled, not available in your region, or not supported for the specific operation. This client-side error (4xx) happens when AWS validates S3 storage class names. Most common when storage class names are misspelled, but also appears when storage classes aren't supported in the region, storage class transitions aren't allowed, or unsupported storage classes are used for operations.
#Common Causes
- →Identity: IAM policy allows S3 operations but storage class invalid. Service Control Policy (SCP) enforces storage class restrictions.
- →Network: VPC endpoint S3 storage class restrictions. Regional storage class availability.
- →Limits: Invalid storage class name. Storage class not supported in region. Storage class typo. Unsupported storage class for operation. Storage class transition not allowed.
✓Solutions
- 1Step 1: Diagnose - Check exact error message: AWS usually specifies which storage class is invalid. Review error message for storage class name. Check for typos.
- 2Step 2: Diagnose - List valid storage classes: Valid classes: STANDARD, STANDARD_IA, ONEZONE_IA, REDUCED_REDUNDANCY, GLACIER, DEEP_ARCHIVE, INTELLIGENT_TIERING. Verify storage class name matches exactly.
- 3Step 3: Diagnose - Check regional availability: Some storage classes may not be available in all regions. Check AWS documentation for regional availability. Verify storage class is supported in your region.
- 4Step 4: Fix - Use correct storage class name: Verify spelling: STANDARD (not STANDARD_STORAGE). Use exact name (case-sensitive). Check if storage class is supported for operation.
- 5Step 5: Fix - Check transition rules: For lifecycle policies, verify transition rules allow storage class. Check if direct upload to storage class is supported. Use appropriate storage class for operation.
</>Code Examples
Validate S3 Storage Class Names
1#!/bin/bash
2# Valid S3 storage classes
3VALID_STORAGE_CLASSES="STANDARD STANDARD_IA ONEZONE_IA REDUCED_REDUNDANCY GLACIER DEEP_ARCHIVE INTELLIGENT_TIERING"
4
5# Validate storage class
6validate_storage_class() {
7 local class=$1
8 if echo "${VALID_STORAGE_CLASSES}" | grep -q "\b${class}\b"; then
9 echo "✓ Valid storage class: ${class}"
10 return 0
11 else
12 echo "✗ Invalid storage class: ${class}"
13 echo "Valid classes: ${VALID_STORAGE_CLASSES}"
14 return 1
15 fi
16}
17
18# Test validation
19STORAGE_CLASS="STANDARD_IA"
20if validate_storage_class "${STORAGE_CLASS}"; then
21 echo "\n=== Uploading with Valid Storage Class ==="
22 echo "aws s3 cp file.txt s3://my-bucket/file.txt --storage-class ${STORAGE_CLASS}"
23else
24 echo "\nFix storage class name before uploading"
25fiCheck Storage Class of Existing Object
1#!/bin/bash
2BUCKET_NAME="my-bucket"
3OBJECT_KEY="file.txt"
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 [ ! -z "${STORAGE_CLASS}" ]; then
13 echo "Storage class: ${STORAGE_CLASS}"
14
15 # Check if valid
16 VALID_CLASSES=("STANDARD" "STANDARD_IA" "ONEZONE_IA" "REDUCED_REDUNDANCY" "GLACIER" "DEEP_ARCHIVE" "INTELLIGENT_TIERING")
17 if [[ " ${VALID_CLASSES[@]} " =~ " ${STORAGE_CLASS} " ]]; then
18 echo "✓ Valid storage class"
19 else
20 echo "✗ Invalid storage class (S3InvalidStorageClass)"
21 fi
22else
23 echo "✗ Object not found or storage class not set"
24fiList Objects by Storage Class
1#!/bin/bash
2BUCKET_NAME="my-bucket"
3STORAGE_CLASS="GLACIER"
4
5echo "=== Listing Objects by Storage Class ==="
6echo "Storage class: ${STORAGE_CLASS}"
7
8aws s3api list-objects-v2 \
9 --bucket ${BUCKET_NAME} \
10 --query "Contents[?StorageClass=='${STORAGE_CLASS}'].[Key,Size,StorageClass]" \
11 --output table
12
13echo "\n=== All Storage Classes in Bucket ==="
14aws s3api list-objects-v2 \
15 --bucket ${BUCKET_NAME} \
16 --query 'Contents[*].StorageClass' \
17 --output text | sort | uniq -c↗Related Errors
Provider Information
This error code is specific to AWS services. For more information, refer to the official AWS documentation.