Writing deny policies for every case is error-prone. S3 Block Public Access gives you four simple switches that override any policy or ACL that would make data public. In this section you replace the bucket policy from section 5 with the new ACLs setting.
confirm and choose Delete.
confirm when asked.
aws s3api put-object --key text01 --body textfile --acl public-read --bucket $bucket
The request is denied with public ACLs are prevented by the BlockPublicAcls setting in S3 Block Public Access – no bucket policy needed.

In production, keep Block all public access turned on at both the account and bucket level unless you have a specific reason not to. To prepare for section 8, edit the setting again and clear the new ACLs option you just selected, so that you can deliberately create a public ACL and detect it.