DEV Community

Cover image for Handy AWS S3 CLI commands
Kyle Foo
Kyle Foo

Posted on • Edited on

Handy AWS S3 CLI commands

Some of the AWS S3 CLI commands that are handy for getting & writing objects to/from the S3 buckets.

To list data from a S3 folder:
aws s3 ls s3://bucket/folder/subfolder/ --recursive --profile kylefoo

To get object from a S3 bucket:
aws s3api get-object --bucket prod-bucket --key folder/subfolder/remote-file.txt --profile kylefoo local-file.txt

To write object to a S3 file:
aws s3api put-object --bucket prod-bucket --key folder/subfolder/remote-object.json --body local-object.json --profile kylefoo

To remove a specific file type inside a S3 subfolder
aws s3 rm s3://bucket/folder/subfolder/ --recursive --exclude "*" --include "*.txt" --profile kylefoo

Top comments (0)