hoangquochung1110 / public-notes

0 stars 0 forks source link

Common AWS S3 CLIs #14

Open hoangquochung1110 opened 2 months ago

hoangquochung1110 commented 2 months ago
  1. Create bucket:

    BUCKET_NAME=
    aws s3 mb s3://$BUCKET_NAME --region=<region>
  2. Update Block Public Access settings

    aws s3api put-public-access-block \
    --bucket $BUCKET_NAME \
    --public-access-block-configuration '{
    "BlockPublicAcls": true,
    "IgnorePublicAcls": true,
    "BlockPublicPolicy": true,
    "RestrictPublicBuckets": true
    }'
hoangquochung1110 commented 2 months ago

Update bucket policy

  1. Create a bucket-policy.json and type/past the policy directly without opening it. Ctrl+D (End-Of-File to save and close)
    
    cat > bucket-policy.json
2. Update policy

aws s3api put-bucket-policy \ --bucket $BUCKET_NAME \ --policy file://bucket-policy.json