Bird
Raised Fist0
AWScloud~5 mins

S3 storage classes (Standard, IA, Glacier) in AWS - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Amazon S3 storage classes help you save money by choosing how often you access your files and how quickly you need them. Different classes like Standard, Infrequent Access (IA), and Glacier offer options for fast access, lower cost for rare access, and long-term archiving.
When you want to keep frequently used files with quick access and high durability.
When you have files you access less often but still need fast retrieval.
When you want to archive files for long-term storage and can wait hours to retrieve them.
When you want to reduce storage costs by moving old backups to cheaper storage.
When you want to balance cost and access speed depending on file usage patterns.
Commands
Create a new S3 bucket named 'example-storage-classes' in the US East (N. Virginia) region to store files with different storage classes.
Terminal
aws s3api create-bucket --bucket example-storage-classes --region us-east-1
Expected OutputExpected
No output (command runs silently)
--bucket - Specifies the name of the bucket to create
--region - Specifies the AWS region for the bucket
Upload 'sample-file.txt' to the bucket using the Standard storage class for frequent access and low latency.
Terminal
aws s3 cp sample-file.txt s3://example-storage-classes/sample-standard.txt --storage-class STANDARD
Expected OutputExpected
upload: ./sample-file.txt to s3://example-storage-classes/sample-standard.txt
--storage-class - Sets the storage class for the uploaded object
Upload the same file using the Standard-Infrequent Access storage class for less frequent access but lower cost.
Terminal
aws s3 cp sample-file.txt s3://example-storage-classes/sample-ia.txt --storage-class STANDARD_IA
Expected OutputExpected
upload: ./sample-file.txt to s3://example-storage-classes/sample-ia.txt
--storage-class - Sets the storage class for the uploaded object
Upload the file using the Glacier storage class for long-term archival storage with retrieval times of hours.
Terminal
aws s3 cp sample-file.txt s3://example-storage-classes/sample-glacier.txt --storage-class GLACIER
Expected OutputExpected
upload: ./sample-file.txt to s3://example-storage-classes/sample-glacier.txt
--storage-class - Sets the storage class for the uploaded object
Check the storage class of the uploaded Glacier object to confirm it was set correctly.
Terminal
aws s3api head-object --bucket example-storage-classes --key sample-glacier.txt
Expected OutputExpected
{ "AcceptRanges": "bytes", "LastModified": "2024-06-01T12:00:00.000Z", "ContentLength": 12345, "ETag": "\"abcdef1234567890abcdef1234567890\"", "StorageClass": "GLACIER", "Metadata": {} }
--bucket - Specifies the bucket name
--key - Specifies the object key (file name)
Key Concept

If you remember nothing else from this pattern, remember: choosing the right S3 storage class balances cost and access speed based on how often and how fast you need your files.

Common Mistakes
Uploading files without specifying the storage class defaults to STANDARD, which can be costly for rarely accessed files.
You pay more for storage when you don't use cheaper classes for infrequent or archival data.
Always specify the storage class flag when uploading files based on their access needs.
Trying to retrieve Glacier objects immediately after upload without initiating a restore.
Glacier objects require a restore process that takes hours before you can access them.
Use the restore API to start retrieval and wait for completion before accessing Glacier objects.
Summary
Create an S3 bucket to hold your files.
Upload files with the --storage-class flag to choose Standard, Standard-IA, or Glacier.
Verify the storage class of objects using the head-object command.

Practice

(1/5)
1. Which Amazon S3 storage class is best for data that you access frequently and need immediately?
easy
A. GLACIER
B. STANDARD_IA (Infrequent Access)
C. ONEZONE_IA
D. STANDARD

Solution

  1. Step 1: Understand S3 storage classes purpose

    STANDARD is designed for frequently accessed data with low latency.
  2. Step 2: Compare with other classes

    STANDARD_IA and GLACIER are for less frequent access and have retrieval delays.
  3. Final Answer:

    STANDARD -> Option D
  4. Quick Check:

    Frequent access = STANDARD [OK]
Hint: Frequent use? Pick STANDARD for fastest access [OK]
Common Mistakes:
  • Choosing GLACIER for frequent access
  • Confusing STANDARD_IA with STANDARD
  • Ignoring retrieval delays in GLACIER
2. Which of the following is the correct way to specify the STANDARD_IA storage class in an AWS CLI command to upload a file?
easy
A. aws s3 cp file.txt s3://bucket/ --storage-class=STANDARDIA
B. aws s3 cp file.txt s3://bucket/ --storageclass STANDARD_IA
C. aws s3 cp file.txt s3://bucket/ --storage-class STANDARD_IA
D. aws s3 cp file.txt s3://bucket/ --storage-class=STANDARD-IA

Solution

  1. Step 1: Recall AWS CLI syntax for storage class

    The correct option uses '--storage-class' with underscore and exact class name.
  2. Step 2: Check each option for syntax errors

    aws s3 cp file.txt s3://bucket/ --storage-class STANDARD_IA matches correct syntax; others have typos or wrong format.
  3. Final Answer:

    aws s3 cp file.txt s3://bucket/ --storage-class STANDARD_IA -> Option C
  4. Quick Check:

    Correct flag and class name = aws s3 cp file.txt s3://bucket/ --storage-class STANDARD_IA [OK]
Hint: Use '--storage-class' exactly with underscore [OK]
Common Mistakes:
  • Misspelling the flag as '--storageclass'
  • Using dashes instead of underscores
  • Omitting the space after the flag
3. You upload a 1 GB file to S3 using the GLACIER storage class. What happens when you try to access the file immediately after upload?
medium
A. The file is instantly available for download.
B. The file is available after a retrieval delay of several hours.
C. The file is deleted automatically after 24 hours.
D. The file is available only if you pay an extra fee upfront.

Solution

  1. Step 1: Understand GLACIER retrieval behavior

    GLACIER stores data for long-term archiving with retrieval delays of hours.
  2. Step 2: Check immediate access options

    Immediate access is not possible; retrieval requires a job that takes time.
  3. Final Answer:

    The file is available after a retrieval delay of several hours. -> Option B
  4. Quick Check:

    GLACIER retrieval delay = hours [OK]
Hint: GLACIER files need hours to retrieve, not instant [OK]
Common Mistakes:
  • Assuming instant access like STANDARD
  • Thinking files auto-delete after upload
  • Believing extra upfront fees enable instant access
4. A user tries to upload a file to S3 with the command: aws s3 cp data.csv s3://mybucket/ --storage-class GLACIER but gets an error. What is the likely cause?
medium
A. GLACIER is not a valid storage class for direct upload via this command.
B. The bucket name is invalid.
C. The file data.csv does not exist locally.
D. The AWS CLI version does not support storage classes.

Solution

  1. Step 1: Understand GLACIER upload restrictions

    GLACIER storage class cannot be used directly in 'aws s3 cp' uploads; use GLACIER via lifecycle or multipart upload.
  2. Step 2: Check other options

    Bucket name and file existence errors produce different messages; CLI supports storage classes.
  3. Final Answer:

    GLACIER is not a valid storage class for direct upload via this command. -> Option A
  4. Quick Check:

    Direct upload with GLACIER = error [OK]
Hint: GLACIER needs lifecycle or special upload, not direct CLI copy [OK]
Common Mistakes:
  • Assuming GLACIER can be set directly on upload
  • Ignoring file existence errors
  • Blaming bucket name without checking
5. You want to store 10 TB of backup data that you rarely access but must keep for years. You want to minimize cost but still be able to retrieve data within a few hours if needed. Which S3 storage class should you choose and why?
hard
A. STANDARD_IA, because it balances lower cost with quick access.
B. STANDARD, because it offers instant access despite higher cost.
C. GLACIER, because it is the cheapest but retrieval takes days.
D. GLACIER INSTANT RETRIEVAL, because it offers low cost and milliseconds access.

Solution

  1. Step 1: Analyze access frequency and retrieval time needs

    Data is rarely accessed but must be retrievable within hours, not instantly.
  2. Step 2: Compare storage classes for cost and retrieval speed

    STANDARD_IA offers lower cost than STANDARD and retrieval in milliseconds to seconds; GLACIER has longer retrieval times.
  3. Final Answer:

    STANDARD_IA, because it balances lower cost with quick access. -> Option A
  4. Quick Check:

    Rare access + quick retrieval = STANDARD_IA [OK]
Hint: Rare access + hours retrieval? Pick STANDARD_IA [OK]
Common Mistakes:
  • Choosing GLACIER despite slow retrieval
  • Picking STANDARD and paying too much
  • Confusing GLACIER INSTANT RETRIEVAL (not standard GLACIER)