File tree Expand file tree Collapse file tree
190-s3-transfer-acceleration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Revision History: 176-s3-encryption
2+
3+ ## Shell (CLI script)
4+
5+ ### 2026-04-14 v1 published
6+ - Type: functional
7+ - Initial version
8+
Original file line number Diff line number Diff line change 11#! /bin/bash
22WORK_DIR=$( mktemp -d) ; exec > >( tee -a " $WORK_DIR /s3-encryption.log" ) 2>&1
3- REGION=${AWS_DEFAULT_REGION:- $(aws configure get region 2>/ dev/ null)} ; [ -z " $REGION " ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4- echo " Step 1: Creating bucket" ; B=" enc-tut-$( openssl rand -hex 4 ) -$( aws sts get-caller-identity --query Account --output text) " ; aws s3api create-bucket --bucket " $B " > /dev/null; echo " Step 2: Enabling SSE-S3" ; aws s3api put-bucket-encryption --bucket " $B " --server-side-encryption-configuration ' {"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}}]}' ; echo " Step 3: Checking encryption" ; aws s3api get-bucket-encryption --bucket " $B " --query " ServerSideEncryptionConfiguration.Rules[0].ApplyServerSideEncryptionByDefault" --output table; echo " Step 4: Uploading encrypted object" ; echo test > /tmp/enc.txt; aws s3 cp /tmp/enc.txt " s3://$B /test.txt" --quiet; aws s3api head-object --bucket " $B " --key test.txt --query " {Encryption:ServerSideEncryption}" --output table; echo " Do you want to clean up? (y/n): " ; read -r C; [[ " $C " =~ ^[Yy]$ ]] && { aws s3 rm " s3://$B " --recursive --quiet; aws s3 rb " s3://$B " ; echo Done; }
3+ REGION=${AWS_DEFAULT_REGION:- ${AWS_REGION :- $ (aws configure get region 2>/ dev/ null) )} ; [ -z "$REGION" ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4+ echo " Step 1: Creating bucket" ; B=" enc-tut-$( cat /dev/urandom | tr -dc ' a-z0-9 ' | fold -w 8 | head -n 1 ) -$( aws sts get-caller-identity --query Account --output text) " ; aws s3api create-bucket --bucket " $B " > / dev/ null; echo " Step 2: Enabling SSE-S3" ; aws s3api put-bucket-encryption --bucket " $B " --server-side-encryption-configuration ' {"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}}]}' ; echo " Step 3: Checking encryption" ; aws s3api get-bucket-encryption --bucket " $B " --query " ServerSideEncryptionConfiguration.Rules[0].ApplyServerSideEncryptionByDefault" --output table; echo " Step 4: Uploading encrypted object" ; echo test > / tmp/ enc.txt; aws s3 cp / tmp/ enc.txt " s3://$B /test.txt" --quiet; aws s3api head-object --bucket " $B " --key test.txt --query " {Encryption:ServerSideEncryption}" --output table; echo " Do you want to clean up? (y/n): " ; read -r C; [[ "$C" =~ ^[Yy]$ ]] && { aws s3 rm " s3://$B " --recursive --quiet; aws s3 rb " s3://$B " ; echo Done; }
Original file line number Diff line number Diff line change 1+ # Revision History: 180-s3-access-points
2+
3+ ## Shell (CLI script)
4+
5+ ### 2026-04-14 v1 published
6+ - Type: functional
7+ - Initial version
8+
Original file line number Diff line number Diff line change 11#! /bin/bash
22WORK_DIR=$( mktemp -d) ; exec > >( tee -a " $WORK_DIR /ap.log" ) 2>&1
3- REGION=${AWS_DEFAULT_REGION:- $(aws configure get region 2>/ dev/ null)} ; [ -z " $REGION " ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; ACCOUNT=$( aws sts get-caller-identity --query Account --output text) ; echo " Region: $REGION "
4- RANDOM_ID=$( openssl rand -hex 4 ) ; BUCKET=" ap-tut-${RANDOM_ID} -${ACCOUNT} " ; AP_NAME=" tut-ap-${RANDOM_ID} "
3+ REGION=${AWS_DEFAULT_REGION:- ${AWS_REGION :- $ (aws configure get region 2>/ dev/ null) )} ; [ -z "$REGION" ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; ACCOUNT=$(aws sts get-caller-identity --query Account --output text); echo " Region: $REGION "
4+ RANDOM_ID=$(cat / dev / urandom | tr -dc ' a-z0-9 ' | fold -w 8 | head -n 1 ); BUCKET=" ap-tut-${RANDOM_ID} -${ACCOUNT} " ; AP_NAME=" tut-ap-${RANDOM_ID} "
55handle_error() { echo " ERROR on line $1 " ; trap - ERR; cleanup; exit 1; } ; trap ' handle_error $LINENO' ERR
66cleanup () { echo " " ; echo " Cleaning up..." ; aws s3control delete-access-point --account-id " $ACCOUNT " --name " $AP_NAME " 2> /dev/null && echo " Deleted access point" ; aws s3 rm " s3://$BUCKET " --recursive --quiet 2> /dev/null; aws s3 rb " s3://$BUCKET " 2> /dev/null && echo " Deleted bucket" ; rm -rf " $WORK_DIR " ; echo " Done." ; }
77echo " Step 1: Creating bucket"
Original file line number Diff line number Diff line change 1+ # Revision History: 186-s3-object-lock
2+
3+ ## Shell (CLI script)
4+
5+ ### 2026-04-14 v1 published
6+ - Type: functional
7+ - Initial version
8+
Original file line number Diff line number Diff line change 11#! /bin/bash
22WORK_DIR=$( mktemp -d) ; exec > >( tee -a " $WORK_DIR /tut.log" ) 2>&1
3- REGION=${AWS_DEFAULT_REGION:- $(aws configure get region 2>/ dev/ null)} ; [ -z " $REGION " ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4- RANDOM_ID=$( openssl rand -hex 4 ) ; ACCOUNT=$( aws sts get-caller-identity --query Account --output text)
3+ REGION=${AWS_DEFAULT_REGION:- ${AWS_REGION :- $ (aws configure get region 2>/ dev/ null) )} ; [ -z "$REGION" ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4+ RANDOM_ID=$(cat / dev / urandom | tr -dc ' a-z0-9 ' | fold -w 8 | head -n 1 ); ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
55B=" lock-tut-${RANDOM_ID} -${ACCOUNT} "
66handle_error() { echo " ERROR on line $1 " ; trap - ERR; cleanup; exit 1; } ; trap ' handle_error $LINENO' ERR
77cleanup () { echo " Cleaning up..." ; echo " Object Lock buckets require all versions to expire before deletion." ; echo " Manual: aws s3api delete-bucket --bucket $B (after retention expires)" ; rm -rf " $WORK_DIR " ; echo " Done." ; }
Original file line number Diff line number Diff line change 1+ # Revision History: 190-s3-transfer-acceleration
2+
3+ ## Shell (CLI script)
4+
5+ ### 2026-04-14 v1 published
6+ - Type: functional
7+ - Initial version
8+
Original file line number Diff line number Diff line change 11#! /bin/bash
22WORK_DIR=$( mktemp -d) ; exec > >( tee -a " $WORK_DIR /tut.log" ) 2>&1
3- REGION=${AWS_DEFAULT_REGION:- $(aws configure get region 2>/ dev/ null)} ; [ -z " $REGION " ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4- RANDOM_ID=$( openssl rand -hex 4 ) ; ACCOUNT=$( aws sts get-caller-identity --query Account --output text)
3+ REGION=${AWS_DEFAULT_REGION:- ${AWS_REGION :- $ (aws configure get region 2>/ dev/ null) )} ; [ -z "$REGION" ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4+ RANDOM_ID=$(cat / dev / urandom | tr -dc ' a-z0-9 ' | fold -w 8 | head -n 1 ); ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
55B=" accel-tut-${RANDOM_ID} -${ACCOUNT} "
66cleanup() { echo " Cleaning up..." ; aws s3 rm " s3://$B " --recursive --quiet 2>/ dev/ null; aws s3 rb " s3://$B " 2>/ dev/ null && echo " Deleted bucket" ; rm -rf " $WORK_DIR " ; echo " Done." ; }
77echo " Step 1: Creating bucket"
Original file line number Diff line number Diff line change 1+ # Revision History: 196-s3-inventory
2+
3+ ## Shell (CLI script)
4+
5+ ### 2026-04-14 v1 published
6+ - Type: functional
7+ - Initial version
8+
Original file line number Diff line number Diff line change 11#! /bin/bash
22WORK_DIR=$( mktemp -d) ; exec > >( tee -a " $WORK_DIR /tut.log" ) 2>&1
3- REGION=${AWS_DEFAULT_REGION:- $(aws configure get region 2>/ dev/ null)} ; [ -z " $REGION " ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4- RANDOM_ID=$( openssl rand -hex 4 ) ; ACCOUNT=$( aws sts get-caller-identity --query Account --output text)
3+ REGION=${AWS_DEFAULT_REGION:- ${AWS_REGION :- $ (aws configure get region 2>/ dev/ null) )} ; [ -z "$REGION" ] && echo " ERROR: No region" && exit 1; export AWS_DEFAULT_REGION=" $REGION " ; echo " Region: $REGION "
4+ RANDOM_ID=$(cat / dev / urandom | tr -dc ' a-z0-9 ' | fold -w 8 | head -n 1 ); ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
55SRC=" inv-src-${RANDOM_ID} -${ACCOUNT} " ; DST=" inv-dst-${RANDOM_ID} -${ACCOUNT} "
66handle_error() { echo " ERROR on line $1 " ; trap - ERR; cleanup; exit 1; } ; trap ' "' " 'handle_error $LINENO '" ' "' ERR
77cleanup () { echo " Cleaning up..." ; aws s3api delete-bucket-inventory-configuration --bucket " $SRC " --id tutorial-inventory 2> /dev/null; aws s3 rm " s3://$SRC " --recursive --quiet 2> /dev/null; aws s3 rb " s3://$SRC " 2> /dev/null; aws s3 rm " s3://$DST " --recursive --quiet 2> /dev/null; aws s3 rb " s3://$DST " 2> /dev/null; rm -rf " $WORK_DIR " ; echo " Done." ; }
You can’t perform that action at this time.
0 commit comments