S3
AWS CLI
Section titled “AWS CLI”List profiles
Section titled “List profiles”aws configure list-profiles
List buckets
Section titled “List buckets”aws s3 ls
List objects in a bucket
Section titled “List objects in a bucket”aws s3 ls s3://{bucket_name}
Copy a file to a bucket
Section titled “Copy a file to a bucket”aws s3 cp {file_path} s3://{bucket_name}
Copy a file from a bucket
Section titled “Copy a file from a bucket”aws s3 cp s3://{bucket_name}/{file_path} {local_path}
Remove a file from a bucket
Section titled “Remove a file from a bucket”aws s3 rm s3://{bucket_name}/{file_path}
Remove all files from a bucket
Section titled “Remove all files from a bucket”aws s3 rm s3://{bucket_name} --recursive
Sync a directory to a bucket
Section titled “Sync a directory to a bucket”aws s3 sync {dir_path} s3://{bucket_name}
Sync a bucket to a directory
Section titled “Sync a bucket to a directory”aws s3 sync s3://{bucket_name} {dir_path}
Setup logs for a bucket
Section titled “Setup logs for a bucket”- Create a log bucket
aws s3 mb s3://{log_bucket_name}
- Setup bucket ACL
aws s3api put-bucket-acl --bucket {log_bucket_name} --grant-write URI=http://acs.amazonaws.com/groups/s3/LogDelivery --grant-read-acp URI=http://acs.amazonaws.com/groups/s3/LogDelivery
- Verify the bucket ACL
aws s3api get-bucket-acl --bucket {log_bucket_name}
- Setup logging for the bucket
aws s3api put-bucket-logging --bucket {bucket_name} --bucket-logging-status '{"LoggingEnabled": {"TargetBucket": "{log_bucket_name}", "TargetPrefix": "{log_prefix}/"}}'
- Verify the bucket logging
aws s3api get-bucket-logging --bucket {bucket_name}
- Visualize the logs
aws s3 ls s3://{log_bucket_name}/{log_prefix}