Write an S3 bucket policy for a specific IAM principal, inspect Block Public Access settings, apply and verify the policy, and simulate permissions ā all from the CLI.
Create a new S3 bucket for this lesson. The bucket name uses your Account ID to ensure global uniqueness.
BUCKET="devopspath-$(aws sts get-caller-identity \
--query Account \
--output text)-policy-lab"echo "Bucket name: $BUCKET"aws s3 mb s3://$BUCKET --region us-east-1The BUCKET shell variable stores the unique bucket name for the rest of this lesson.
Using your 12-digit Account ID in the name guarantees global uniqueness without a random suffix.
The variable is set in the current shell session ā if you open a new terminal window you will need to re-run the first command to restore it.
The echo command prints a name like: devopspath-123456789012-policy-lab
The mb command outputs: make_bucket: devopspath-123456789012-policy-lab
The bucket now exists in us-east-1.