AWS CLI – Amazon S3 GLACIER on S3 Service

      PUT object

Use below AWS CLI command:

aws s3api put-object --bucket <BUCKET NAME> --key <FILE NAME> --body <FILE PATH> --storage-class <S3 STORAGE CLASS>

 

Where

BUCKET NAME – The bucket name to which the PUT action was initiated

FILE NAME – Object key for which the PUT action was initiated

FILE PATH – Provide complete location of file along with file name

S3 STORAGE CLASS – can be any of following; Glacier options are highlighted.

·       STANDARD

·       REDUCED_REDUNDANCY

·       STANDARD_IA

·       ONEZONE_IA

·       INTELLIGENT_TIERING

·       GLACIER ----S3 Glacier Flexible Retrieval, formerly S3 Glacier

·       DEEP_ARCHIVE ---- S3 Glacier Deep Archive

·       OUTPOSTS

·       GLACIER_IR ---- S3 Glacier Instant Retrieval

 E.g.

aws s3api put-object --bucket demobucketclitest --key AWS_MAP_GLACIER.pdf --body D:\Downloads\AWSPartnerMAPWalkingDeck2022-English.pdf --storage-class GLACIER

Quick Reference - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/put-object.html  


      GET object

To downloading objects which are stored in GLACIER and DEEP_ARCHIVE storage class has 2 step process viz. Restore object and download object. For GLACIER_IR, one can download directly without restore operation.

 

a.       Restore Object

Use below AWS CLI command:

aws s3api restore-object --bucket <BUCKET NAME> --key <FILE NAME> --restore-request ‘{“Days”=<RETENTION DAYS>,”GlacierJobParameters”:{“Tier”:”<TIER>”}}’

 

Where

            BUCKET NAME – The bucket name containing the object to restore

            FILE NAME – Provide name of file/object to be restored

            RETENTION DAYS – Lifetime of the active copy in days

            TIER - Retrieval tier at which the restore will be processed – Standard | Bulk | Expedited


E.g.

aws s3api restore-object --bucket demobucketclitest --key AWS_MAP_GLACIER.pdf --restore-request '{"Days":1,"GlacierJobParameters":{"Tier":"Expedited"}}'

Note - If the JSON syntax used in the example results in an error on a Windows client, replace the restore request with the following syntax:

--restore-request Days=1,GlacierJobParameters={"Tier"="Expedited"}


To monitor the status of your restore-object request, use the following command:

aws s3api head-object --bucket <BUCKET NAME> --key <FILE NAME>

 

Where

            BUCKET NAME – The bucket name containing the object to restore

            FILE NAME – Provide name of file/object to be restored

 

E.g.

aws s3api head-object --bucket demobucketclitest --key AWS_MAP_GLACIER.pdf

                        Quick Reference - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/restore-object.html


b.      
Download object

Use below AWS CLI command:

aws s3api get-object --bucket <BUCKET NAME> --key <FILE NAME> <OUTPUT FILE NAME>

 

Where

            BUCKET NAME – The bucket name containing the object to restore

FILE NAME – Provide name of file/object to be restored

OUTPUT FILE NAME – Provide full path and file name for output

 

E.g

aws s3api get-object --bucket demobucketclitest --key AWS_MAP_GLACIER.pdf D:\AWS_MAP_GLACIER_download.pdf

Quick Reference - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/get-object.html 


Comments

Popular posts from this blog

Oracle Cloud Infrastructure