Limit IpAddress while uploading to aws s3 bucket using aws post policy

0

I want to restrict the upload to specific IP address while using the aws post policies, how can this be done, if not then what are the alternates ??

2 個答案
0

You can use a bucket policy to specify which IP can access an S3 bucket. Please see a detailed blog with some samples: https://aws.amazon.com/premiumsupport/knowledge-center/block-s3-traffic-vpc-ip/

AWS
dsp
已回答 1 年前
0

When a user uses a S3 pre-signed URL, the credentials and permissions of the creator of the URL are used to access the object. So, if you want to restrict the PUT of the object to a specific IP address you use a policy like this, attached to the role/user that creates the presigned URL.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1670849877919",
      "Action": [
        "s3:PutObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::mybucket/*",
      "Condition": {
        "IpAddress": {
          "aws:SourceIp": "192.168.1.45/32"
        }
      }
    }
  ]
}

You can also attach a bucket policy to the bucket and denies all other requests to lock down the bucket to only this source IP.

{
  "Id": "Policy1670850160564",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1670850159333",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:s3:::mybucket",
        "arn:aws:s3:::mybucket/*"
      ],
      "Condition": {
        "NotIpAddress": {
          "aws:SourceIp": "192.168.1.45/32"
        }
      },
      "Principal": "*"
    }
  ]
}
profile pictureAWS
專家
kentrad
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南