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

128
Views
aws policy for read/write to a file within a bucket

I have the following s3 structure:

bucket name: test-bucket

file: test.json

And I have the following aws policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Action": "s3:GetObject",
            "Action": "s3:DeleteObject",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::test-bucket"
        }
    ]
}

And this policy is attached to a user with access key 123.

When I try to put or get the test.json in the test-bucket using the sdk as this:

BasicAWSCredentials awsCreds = new BasicAWSCredentials("123", "secretKeyId");
s3Client = AmazonS3ClientBuilder.standard()
                        .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                        .withRegion("US-EAST-1")
                        .build();
s3Client.putObject(new PutObjectRequest("test-bucket", "test.json", file));

This will give the access deny problem.

If I change the policy's resource to

 "Resource": "*"

then it will work. I just want to make sure the resource I put is in correct format. What went wrong?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to let amazon know that beside your bucket you also want to access content of your bucket.

So change resource from:

"Resource": "arn:aws:s3:::test-bucket"

To something like:

"Resource": [
    "arn:aws:s3:::test-bucket",
    "arn:aws:s3:::test-bucket/*"
]
about 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!