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 Antworten
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
beantwortet vor einem Jahr
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
EXPERTE
kentrad
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen