i have used below policy but its locked me out of bucket. now its asking or root access

0

{ "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": "*" } ] }

ali
질문됨 일 년 전346회 조회
2개 답변
2

I understand that with the bucket policy listed above, you are locked out. To solve this problem, you need to use your root user credentials and follow steps as below:

  1. export AWS_DEFAULT_REGION= <region_name>

  2. export AWS_ACCESS_KEY_ID="ROOT_ACCESS_KEY_ID"

  3. export AWS_SECRET_ACCESS_KEY="ROOT_SECRET_KEY_ID"

  4. aws s3api delete-bucket-policy --bucket s3-bucket-name

Note: For windows use "set" instead of "export" while using CLI

This would delete the s3 bucket policy and you should be able to access the bucket. Next thing to make sure when you put bucket policy is, never add all the actions in deny statement, unless you are not sure what each of those action does exactly.

You can start with something like this and then start tweaking it further to add securetransport condition in second block(listed below), this policy would make sure that you always have access to the bucket to perform actions on it and you are not locked out.

   {
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": {
           "AWS": "<your user arn or role arn would come here>"
         },
         "Action": [
           "s3:*"
         ],
         "Resource": [
           "arn:aws:s3:::bucket_name",
           "arn:aws:s3:::bucket_name/*"
         ]
       },
       {
         "Effect": "Deny",
         "NotPrincipal": {
           "AWS": "<your user arn or role arn would come here>"
          },
         "Action": [
           "s3:*"
         ],
         "Resource": [
           "arn:aws:s3:::bucket_name",
           "arn:aws:s3:::bucket_name/*"
         ]
       }
     ]
   }
profile pictureAWS
전문가
답변함 일 년 전
1

Hello, Mentioned policy is to only allow encrypted connections via HTTPS and restricting HTTP requests from accessing your bucket. Can you please elaborate more what it means by locked out or asking root access. Any errors ?

AWS
답변함 일 년 전

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

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

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

관련 콘텐츠