Policy bucket force SSL

0

Hello, I would like to know how I can insert a policy in a bucket to accept only SSL connections. I used this policy model below and from testing it did not work.

{ "Version": "2012-10-17", "Statement": [{ "Sid": "RestrictToTLSRequestsOnly", "Action": "s3:", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/" ], "Condition": { "Bool": { "aws:SecureTransport": "false" } }, "Principal": "*" }] }

Felipe
질문됨 한 달 전85회 조회
2개 답변
2
수락된 답변

Hello.

I think you can limit access to only HTTPS by setting the bucket policy described in the document below.
https://repost.aws/knowledge-center/s3-bucket-policy-for-config-rule

{
  "Id": "ExamplePolicy",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowSSLRequestsOnly",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:s3:::DOC-EXAMPLE-BUCKET",
        "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      },
      "Principal": "*"
    }
  ]
}

You can check the settings by running the following command.
You can confirm that if you explicitly send a request via HTTP with "--endpoint-url", it will be rejected.

# Success
aws s3 ls s3://s3-bucket-name/ --endpoint-url https://s3.ap-northeast-1.amazonaws.com

# Fail
aws s3 ls s3://s3-bucket-name/ --endpoint-url http://s3.ap-northeast-1.amazonaws.com
profile picture
전문가
답변함 한 달 전
profile picture
전문가
검토됨 한 달 전
profile pictureAWS
전문가
검토됨 한 달 전
1

It looks like you have followed this, but missed a couple of wildcards https://repost.aws/knowledge-center/s3-bucket-policy-for-config-rule

Your "Action": "s3:", entry should be "Action": "s3:*",

Similarly "arn:aws:s3:::DOC-EXAMPLE-BUCKET/" needs to be "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*"

(I think it's the first one that is more important)

profile picture
전문가
Steve_M
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠