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 Answers
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
answered a year ago
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
EXPERT
kentrad
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions