Require HTTPS

Require HTTPS

Amazon S3 accepts requests over both HTTP and HTTPS. To make sure data is always encrypted in transit, add a bucket policy that denies any request where aws:SecureTransport is false.

  1. In the S3 console, open your bucket and choose the Permissions tab.
  2. Under Bucket policy, choose Edit.

Bucket permissions

  1. Paste the following policy and choose Save changes:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "RequireHTTPS",
            "Action": "s3:*",
            "Effect": "Deny",
            "Principal": "*",
            "Resource": "arn:aws:s3:::<your-bucket-name>/*",
            "Condition": {
                "Bool": {
                    "aws:SecureTransport": "false"
                }
            }
        }
    ]
}

Require HTTPS policy

  1. In the Session Manager terminal, read the object metadata over HTTP and then over HTTPS:
aws s3api head-object --key app1/file1 --endpoint-url http://s3.ap-northeast-1.amazonaws.com --bucket $bucket
aws s3api head-object --key app1/file1 --endpoint-url https://s3.ap-northeast-1.amazonaws.com --bucket $bucket

The HTTP request fails with 403 Forbidden; the HTTPS request succeeds.

HTTP denied, HTTPS allowed

Change ap-northeast-1 in the endpoint URL if you use a different Region.