Mở console CloudFront, chọn Create distribution.

Ở Get started:
fcj-chat-app.
Ở Specify origin, giữ origin type là Amazon S3.

Cuộn xuống:

Ở Enable security:

Đợi đến khi Last modified hiện ngày giờ thay cho Deploying (khoảng 5 phút). Lưu ID và domain của distribution trong CloudShell:
echo 'export DIST_ID=<distribution-id>' >> ~/chat.env && source ~/chat.env
echo "export CF_DOMAIN=$(aws cloudfront get-distribution --id $DIST_ID --query Distribution.DomainName --output text)" >> ~/chat.env && source ~/chat.env
Mở https://<distribution-domain>/chats.html trên trình duyệt.

So sánh hai đường truy cập vào cùng một file:
curl -s -o /dev/null -w 'CloudFront: %{http_code}\n' https://$CF_DOMAIN/chats.html
curl -s -o /dev/null -w 'S3 direct: %{http_code}\n' https://$BUCKET.s3.ap-northeast-1.amazonaws.com/chats.html
200, còn URL S3 trực tiếp trả 403. Chỉ distribution mới đọc được bucket.