Skip to content

AWS

aws — AWS CLI 2.13.29 Command Reference

How-to

configure

create profile
aws configure --profile my-profile

list current profiles
aws configure list-profiles
export AWS_PROFILE=xxx
Retrieve instance metadata - Amazon Elastic Compute Cloud

http://169.254.169.254/latest/meta-data/

S3

s3 sync
aws s3 sync --profile <some-profile> <source_path> <target_path>
count object numbers and size
aws s3 ls s3://my-bucket/path/to --recursive --human-readable --summarize

最後會列出Total Objects, 跟Total Size

add metadata to all objects in bucket
aws s3 cp --recursive --metadata-directive REPLACE --content-type "image/jpeg" s3://your-bucket-name/ s3://your-bucket-name/
set all objects public-read
aws s3 ls s3://my-bucket/path/to/ --recursive | awk -F ' ' '{cmd="aws s3api put-object-acl --acl public-read --bucket mybucket --key "$4; system(cmd)}'

,取後面的key,然後用神奇的awk,搭配 system執行命令。