Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
s3 bucket policy post

I'm trying to do a post to my bucket, and I'm a little confused on how the policy for the formdata is supposed to match the policy for my bucket.

 @time = Time.now.utc
 @time_policy = @time.strftime('%Y%m%dT000000Z')
 @date_stamp = @time.strftime('%Y%m%d')

 ret = {"expiration" => 1.day.from_now.utc.xmlschema,
        "conditions" =>  [
            {"bucket" => Rails.application.secrets.aws_bucket},
            {"x-amz-credential": "#{Rails.application.secrets.aws_access_key_id}/#{@date_stamp}/us-west-2/s3/aws4_request"},
            {"x-amz-algorithm": "AWS4-HMAC-SHA256"},
            {"x-amz-date": @time_policy },
        ]
        }

  @policy = Base64.encode64(ret.to_json).gsub(/\n|\r/, '')

Bucket Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Allow Get",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::example-development/*"
        },
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789:user/example"
            },
            "Action": "s3:*",
            "Resource": ["arn:aws:s3:::example-development/*","arn:aws:s3:::example-development"]
        }
    ]
}

Do these match? I haven't stumbled upon any documentation that shows a good side by side comparison of the two.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The conditions are independent to the policy.

The conditions enforce particular attributes of the upload. For example, { "{acl": "public-read" } enforces the rule that the upload must set the ACL to public-read. If the upload doesn't set that value, the upload will be rejected.

The bucket policy is enforced whenever something tries to access Amazon S3. So, "s3:x-amz-acl": "public-read" says that people can access the bucket as long as that value is true. This is a very strange thing to put in a bucket policy, because that attribute is only relevant for a PutObject operation. When reading an object from S3, it does not apply.

See Specifying Conditions in a Policy for an example of it with using PutObject.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!