Tome A
Tome A

Reputation: 43

How do I update the meta-data of a directory using aws s3 cli?

I am attempting to use the following command in a bash script to update the x-amz-meta-uid and x-amz-meta-gid of files and folders recursively.

aws s3 cp s3://$SOURCE_CLOUD_BUCKET_PATH s3://$DESTINATION_CLOUD_BUCKET_PATH --recursive --quiet --metadata-directive "REPLACE" --metadata "uid=$USER_UID,gid=$USER_GID"

However, it only seems to be updating the metadata on files. How can I also get this to update the metadata on the directories/folders also?

aws --version

aws-cli/2.0.43 Python/3.7.3 Linux/5.4.0-1029-aws exe/x86_64.ubuntu.18

Upvotes: 3

Views: 2493

Answers (2)

Sumit Kumar
Sumit Kumar

Reputation: 760

No need to change the metadata of the files recursively, Metadata of whole folder can be changed. Follow this

Upvotes: 0

Atul Sharma
Atul Sharma

Reputation: 10645

As AWS S3 document states : https://docs.aws.amazon.com/AmazonS3/latest/user-guide/using-folders.html

In Amazon S3, buckets and objects are the primary resources, and objects are stored in buckets. Amazon S3 has a flat structure instead of a hierarchy like you would see in a file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. Amazon S3 does this by using a shared name prefix for objects (that is, objects have names that begin with a common string). Object names are also referred to as key names.

Since AWS S3 is Object storage service and is not POSIX compliant.

Which means there is no disk level folder structure maintainer.

The folders you are seeing are logical which means a file with name hello/world.text will show hello as parent folder name while world.txt as file name however, the actual filename stored is hello/world.txt.

So the meta-data is also managed at file level and not at folder level since, their are no physical folders.

The CLI behaviour is correct and you need to modify meta-data of files. Though, you can modify meta-data of all files / multiple files in a go.

Upvotes: 1

Related Questions