Commands
Progress checklist
Overview
Section titled “Overview”Copy-paste index. Prefer the walkthrough pages for context. Names match scripts/demo.sh /
scripts/image.sh.
export AWS_PROFILE=sandboxexport AWS_REGION=ap-southeast-2export LAB_SUFFIX=${LAB_SUFFIX:-$(date +%Y%m%d%H%M%S)}export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)export NAME="s3x-hotlookup-${LAB_SUFFIX}"export STD_BUCKET="s3x-hotlookup-${LAB_SUFFIX}-${ACCOUNT_ID}"export DIR_BUCKET="s3x-hotlookup-${LAB_SUFFIX}--apse2-az1--x-s3"export ROLE_NAME="s3x-hotlookup-${LAB_SUFFIX}-ec2"export PROFILE_NAME="s3x-hotlookup-${LAB_SUFFIX}-profile"mkdir -p .lab| Name | Pattern |
|---|---|
| Standard bucket | s3x-hotlookup-${LAB_SUFFIX}-${ACCOUNT_ID} |
| Directory bucket | s3x-hotlookup-${LAB_SUFFIX}--apse2-az1--x-s3 |
| Role / profile | …-ec2 / …-profile |
| Tag | Project=s3-express-hot-lookup-walkthrough |
Image pipeline (durable)
Section titled “Image pipeline (durable)”export S3X_LAB_ALLOW_AWS=1./scripts/image.sh up./scripts/image.sh build./scripts/image.sh status# when finished with the account forever:# ./scripts/image.sh downSetup — AZ, VPC, endpoints
Section titled “Setup — AZ, VPC, endpoints”export AZ_NAME=$(aws ec2 describe-availability-zones \ --zone-ids apse2-az1 \ --query 'AvailabilityZones[0].ZoneName' --output text)
aws ec2 create-vpc --cidr-block 10.87.0.0/16 \ --tag-specifications "ResourceType=vpc,Tags=[{Key=Name,Value=${NAME}-vpc},{Key=Project,Value=s3-express-hot-lookup-walkthrough}]"
# … subnet in $AZ_NAME, IGW, public route, security group …
aws ec2 create-vpc-endpoint \ --vpc-id "$VPC_ID" \ --service-name com.amazonaws.ap-southeast-2.s3 \ --route-table-ids "$RTB_ID"
aws ec2 create-vpc-endpoint \ --vpc-id "$VPC_ID" \ --service-name com.amazonaws.ap-southeast-2.s3express \ --route-table-ids "$RTB_ID"Setup — buckets
Section titled “Setup — buckets”aws s3api create-bucket \ --bucket "$STD_BUCKET" \ --create-bucket-configuration "LocationConstraint=${AWS_REGION}"
aws s3api put-bucket-tagging \ --bucket "$STD_BUCKET" \ --tagging "TagSet=[{Key=Project,Value=s3-express-hot-lookup-walkthrough}]"
aws s3api create-bucket \ --bucket "$DIR_BUCKET" \ --create-bucket-configuration '{ "Location": { "Type": "AvailabilityZone", "Name": "apse2-az1" }, "Bucket": { "DataRedundancy": "SingleAvailabilityZone", "Type": "Directory" } }' \ --region "$AWS_REGION"
# Directory buckets: TagResource (not put-bucket-tagging)aws s3control tag-resource \ --account-id "$ACCOUNT_ID" \ --resource-arn "arn:aws:s3express:${AWS_REGION}:${ACCOUNT_ID}:bucket/${DIR_BUCKET}" \ --tags "Key=Project,Value=s3-express-hot-lookup-walkthrough"Setup — IAM and EC2
Section titled “Setup — IAM and EC2”aws iam create-role \ --role-name "$ROLE_NAME" \ --assume-role-policy-document file://.lab/ec2-trust.json \ --tags Key=Project,Value=s3-express-hot-lookup-walkthrough
aws iam put-role-policy \ --role-name "$ROLE_NAME" \ --policy-name "s3x-hotlookup-s3" \ --policy-document file://.lab/ec2-permissions.json
aws iam attach-role-policy \ --role-name "$ROLE_NAME" \ --policy-arn arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
aws iam create-instance-profile --instance-profile-name "$PROFILE_NAME"aws iam add-role-to-instance-profile \ --instance-profile-name "$PROFILE_NAME" \ --role-name "$ROLE_NAME"
aws ec2 run-instances \ --image-id "$AMI_ID" \ --instance-type m7g.large \ --subnet-id "$SUBNET_ID" \ --security-group-ids "$SG_ID" \ --iam-instance-profile "Name=${PROFILE_NAME}" \ --user-data file://.lab/user-data.sh \ --associate-public-ip-address \ --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=${NAME}-harness},{Key=Project,Value=s3-express-hot-lookup-walkthrough}]"Seed and observe
Section titled “Seed and observe”Directory buckets reject aws s3 sync — use recursive cp for Express.
aws s3 sync .lab/seed/hot/ "s3://${STD_BUCKET}/hot/"aws s3 cp .lab/seed/hot/ "s3://${DIR_BUCKET}/hot/" --recursive
aws s3api list-objects-v2 --bucket "$STD_BUCKET" --prefix hot/ \ --query 'length(Contents)' --output textaws s3api list-objects-v2 --bucket "$DIR_BUCKET" --prefix hot/ \ --query 'length(Contents)' --output textDashboard
Section titled “Dashboard”./scripts/demo.sh dash./scripts/demo.sh port-forward# or:aws ssm start-session \ --target "$(jq -r .instanceId .lab-state.json)" \ --document-name AWS-StartPortForwardingSession \ --parameters '{"portNumber":["8080"],"localPortNumber":["8080"]}'
curl -sS "http://127.0.0.1:8080/api/stats" | jq '{ express: .express|{count,errors,p50_ms}, standard: .standard|{count,errors,p50_ms}, standard_over_express_p50}'Tear down (everything)
Section titled “Tear down (everything)”export S3X_LAB_ALLOW_AWS=1./scripts/demo.sh down # LAB_SUFFIX confirm — lab VPC, buckets, EC2, lab IAM./scripts/image.sh down # ECR repo name confirm — ECR, CodeBuild, source bucketManual lab order (wrappers preferred; still run image.sh down after):
aws ec2 terminate-instances --instance-ids "$INSTANCE_ID"aws s3 rm "s3://${STD_BUCKET}" --recursiveaws s3api delete-bucket --bucket "$STD_BUCKET"aws s3 rm "s3://${DIR_BUCKET}" --recursiveaws s3api delete-bucket --bucket "$DIR_BUCKET"# endpoints → subnet / routes / IGW → VPC → detach SSM policy → IAMWrappers
Section titled “Wrappers”export S3X_LAB_ALLOW_AWS=1./scripts/image.sh up|build|status|down./scripts/demo.sh up|status|seed|harness|dash|port-forward|down