The Minimum IAM Policy for an S3 Web Client: One Bucket, Least Privilege

On this page
The quickest policies to give a web file manager’s access key are the broad ones. AWS’s managed AdministratorAccess policy allows "Action" : "*" on "Resource" : "*", and AmazonS3FullAccess allows s3:* on every resource, so either key works on every bucket in the account.
AWS’s IAM guidance is to “grant only the permissions required to perform a task”, and it warns that AWS managed policies “might not grant least-privilege permissions” for your use. It prefers temporary credentials, but names third-party clients that don’t support IAM Identity Center as the case for an IAM user’s long-term access keys, which is where a web client sits.
This guide trims AWS’s one-bucket example to browse, upload, download and delete, adds what large uploads need, and shows how to test the result with a throwaway user. The result is a minimum IAM policy for an S3 web client that is narrower than s3:*; this post claims nothing more for it.
In this guide:
- The minimum IAM policy for an S3 web client
- AWS’s one-bucket example, trimmed for a web client
- The three resource scopes behind the two statements
- Large files: the three multipart actions
- Actions to add for your client or bucket
- Test the policy with a throwaway user
- R2, B2, Wasabi, MinIO and Spaces scope keys differently
The minimum IAM policy for an S3 web client
A browser file manager that browses, uploads, downloads and deletes in one bucket needs two statements. s3:ListBucket goes on the bucket ARN, arn:aws:s3:::<BUCKET>. s3:GetObject, s3:PutObject and s3:DeleteObject go on the object ARN, arn:aws:s3:::<BUCKET>/*. Uploads large enough for multipart add three more actions, split the same way.
The split follows AWS’s Required permissions for Amazon S3 API operations and its multipart upload overview:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BucketLevel",
"Effect": "Allow",
"Action": ["s3:ListBucket", "s3:ListBucketMultipartUploads"],
"Resource": "arn:aws:s3:::<BUCKET>"
},
{
"Sid": "ObjectLevel",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:AbortMultipartUpload",
"s3:ListMultipartUploadParts"
],
"Resource": "arn:aws:s3:::<BUCKET>/*"
}
]
}Replace <BUCKET> (a placeholder) with your bucket’s name in both places. The aws after arn: is the partition in AWS’s ARN format, so an account in another partition changes it too.
The policy leaves out other buckets, the region lookup, ACLs, object versions and bucket settings. The sections below say when to add one back.
AWS’s one-bucket example, trimmed for a web client
AWS’s one-bucket example has three statements: s3:ListAllMyBuckets alone on "*", s3:ListBucket and s3:GetBucketLocation on the bare bucket ARN, and s3:PutObject, s3:PutObjectAcl, s3:GetObject, s3:GetObjectAcl and s3:DeleteObject on bucket/* only.
The same page says its examples “will work if you use them programmatically”, and calls ListAllMyBuckets, GetBucketLocation and ListBucket “the additional permissions required by the console”. It says the two ACL actions are required “to copy, cut, and paste objects in the console”. A web client calls the API directly, so each console extra has to earn its place:
| Action in AWS’s example | API call it allows | For a web client |
|---|---|---|
s3:ListAllMyBuckets on "*" |
ListBuckets, the list of every bucket you own (AWS) | Drop it if you give the client the bucket name |
s3:GetBucketLocation on the bucket |
GetBucketLocation, which returns the bucket’s region (AWS) | Drop it if you give the client the region; AWS doesn’t say so outright, so test it |
s3:ListBucket on the bucket |
ListObjectsV2 and HeadBucket (AWS) | Keep |
s3:GetObject, s3:PutObject, s3:DeleteObject on bucket/* |
Download, upload and delete (AWS) | Keep |
s3:PutObjectAcl, s3:GetObjectAcl on bucket/* |
Setting an ACL on upload, showing object owner information (AWS) | Drop: new buckets have ACLs disabled by default, and PUT requests with any ACL other than bucket-owner-full-control then fail (AWS); a client that doesn’t show object owner information doesn’t need s3:GetObjectAcl (AWS) |
The three resource scopes behind the two statements
Each S3 action belongs to one resource scope, and the statement’s Resource has to match it. AWS’s required-permissions page names three:
- Bucket operations need the bucket ARN as the
Resource. - Object operations need the object ARN.
- Account operations, such as ListBuckets, need
"*".
Each action’s Resource must be its own scope. The minimum policy is the bucket statement and the object statement. The dashed actions are optional extras, and s3:ListAllMyBuckets needs a statement of its own. We put s3:ListBucketMultipartUploads on the bucket, as AWS’s multipart overview says, but haven’t run the placement test.
Listing a folder with ListObjectsV2 is a bucket operation, while GetObject, PutObject and DeleteObject are object operations (How Amazon S3 works with IAM). The object ARN “must contain a forward slash after the bucket name”, so a policy that puts s3:GetObject only on arn:aws:s3:::<BUCKET> allows no downloads.
Account-level actions need a statement of their own. AWS’s policy editor guide says an action on "*" and an action on a specific ARN “must be in two separate JSON statements”, which is why adding s3:ListAllMyBuckets means a third statement.
What each file-manager action calls
| You click | S3 API call | IAM action | Resource | Source |
|---|---|---|---|---|
| Open a folder | ListObjectsV2 | s3:ListBucket |
bucket | AWS |
| Download or preview | GetObject | s3:GetObject |
bucket/* |
AWS |
| File details (size, type) | HeadObject | s3:GetObject |
bucket/* |
AWS |
| Upload | PutObject, or multipart for large files | s3:PutObject |
bucket/* |
AWS |
| Rename or move | CopyObject, then DeleteObject | s3:GetObject on the source, s3:PutObject on the destination, then s3:DeleteObject |
bucket/* |
AWS |
| Delete a folder | ListObjectsV2, then DeleteObjects | s3:ListBucket, then s3:DeleteObject |
bucket, then bucket/* |
AWS |
| Share link | Presigned GetObject | s3:GetObject, held by the signing key |
bucket/* |
AWS |
A rename is a copy plus a delete, so a key without s3:DeleteObject copies the file and leaves the old one in place. Copying into a second bucket needs that bucket in the policy too, because the copy needs s3:PutObject on the destination.
A share link can do only what its signer can. AWS says “the capabilities of a presigned URL are limited by the permissions of the user who created it”, and calls presigned URLs “bearer tokens”.
For a 403 SignatureDoesNotMatch on a browser upload, see fix SignatureDoesNotMatch on browser uploads.
A missing file returns 403 without ListBucket
AWS’s GetObject reference says a request for a missing key returns “404 Not Found” if the caller has s3:ListBucket on the bucket, and “403 Access Denied” if not. Without s3:ListBucket, a missing file looks like a permissions problem, and the test program below checks for this.
Large files: the three multipart actions
AWS calls multipart upload a best practice “for objects that are 100 MB or larger”, and each client decides when it switches to it. s3:PutObject covers starting the upload, uploading each part and completing it (AWS), but three actions are separate:
s3:AbortMultipartUploadstops an upload. It goes onbucket/*.s3:ListMultipartUploadPartslists the parts of one upload. It goes onbucket/*.s3:ListBucketMultipartUploadslists the uploads in progress in a bucket. It goes on the bucket ARN.
The API call is named ListMultipartUploads, but the IAM action that allows it is s3:ListBucketMultipartUploads (AWS), so a policy that names s3:ListMultipartUploads doesn’t grant the call.
AWS’s pages disagree on where that action goes. The required-permissions page lists the ListMultipartUploads row among object operations, while the multipart overview says the action is allowed “on a bucket”. This policy follows the overview, and AWS’s Service Authorization Reference agrees: it lists the bucket as the resource type for s3:ListBucketMultipartUploads. We haven’t run the placement test described below, so run it before you rely on either page.
Unfinished uploads cost storage: AWS says you “must either complete or stop the multipart upload to stop incurring charges”. It recommends a lifecycle rule with AbortIncompleteMultipartUpload (AWS), which you set on the bucket with admin credentials; the client’s key needs no permission for it.
Actions to add for your client or bucket
Add an action only when the test below fails without it, or when your bucket’s setup needs it:
| If | Add | Resource | Source |
|---|---|---|---|
| The client lists your buckets so you can pick one | s3:ListAllMyBuckets |
"*", in its own statement |
AWS |
| The client looks up the bucket’s region | s3:GetBucketLocation |
bucket | AWS |
| The bucket is versioned and the client reads or deletes specific versions | s3:GetObjectVersion, s3:DeleteObjectVersion |
bucket/* |
AWS |
| The client lists object versions | s3:ListBucketVersions |
bucket | AWS |
| The bucket encrypts with an AWS KMS customer managed key | kms:GenerateDataKey for uploads; kms:Decrypt for downloads and multipart uploads |
the KMS key | AWS, AWS |
| The bucket still uses ACLs and the client sets them | s3:PutObjectAcl, s3:GetObjectAcl |
bucket/* |
AWS |
The KMS actions go in a statement of their own, with the key’s ARN as the resource.
Limit the key to one folder
To confine the key to one folder, change the object statement’s resource to arn:aws:s3:::<BUCKET>/<FOLDER>/* and add an s3:prefix condition to s3:ListBucket. AWS’s per-user folder example does both, using ${aws:username} where this fragment has the placeholder <FOLDER>:
{
"Sid": "ListOnlyTheFolder",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::<BUCKET>",
"Condition": { "StringLike": { "s3:prefix": ["<FOLDER>/*"] } }
}Remove s3:ListBucket from the BucketLevel statement and keep s3:ListBucketMultipartUploads there; an unconditioned s3:ListBucket alongside this statement still lists the whole bucket.
AWS’s example also adds a listing statement with an empty s3:prefix and a / s3:delimiter, so the user can open the bucket root and see the folder. Left without a condition, s3:ListBucketMultipartUploads still lists in-progress uploads for the whole bucket. We haven’t tested this fragment, and how a client’s list requests meet the condition depends on the prefix and delimiter it sends, so run the test program with PREFIX inside the folder.
Test the policy with a throwaway user
IAM denies by default: AWS says a policy “must explicitly allow the principal to perform an action”, and anything missing fails with HTTP 403. Test with a user that holds only this policy, never with your admin key. The steps use the placeholder <TEST_USER> and an inline policy named web-client-one-bucket, which the console deletes together with the user.
Console steps
The labels come from AWS’s IAM User Guide as read on 2026-11-23.
- Open the IAM console at
https://console.aws.amazon.com/iam/. In the navigation pane, choose Users, then Create user (AWS). - On Specify user details, enter a User name and choose Next. Leave console access off: AWS says to “Create only the credentials that the user needs”.
- On Set Permissions, which is optional, add nothing and choose Next.
- Review the user, then choose Create user. In the status notification, choose View user.
- On the user’s page, open the Permissions tab. Choose Add permissions, then Create inline policy (AWS).
- In the Policy editor, choose JSON and paste the policy. Resolve any warnings from policy validation, then choose Next (AWS).
- On Review and create, enter
web-client-one-bucketas the Policy Name and choose Create policy. - Open the Security credentials tab. In Access keys, choose Create access key (AWS).
- On Access key best practices & alternatives, choose Other, then Next.
- On Set description tag, which is optional, choose Create access key.
- On Retrieve access key, choose Show or Download .csv file. AWS says a lost secret “cannot be recovered, and you must create a new access key”.
The same steps with the AWS CLI
Save the policy as policy.json and run these with your admin credentials (create-user, put-user-policy, create-access-key):
aws iam create-user --user-name <TEST_USER>
aws iam put-user-policy --user-name <TEST_USER> \
--policy-name web-client-one-bucket --policy-document file://policy.json
aws iam create-access-key --user-name <TEST_USER>put-user-policy “adds or updates” an inline policy, so re-running it with an edited policy.json is how you try a variant.
Check every action with one Python program
The program runs each call a file manager makes with the throwaway key and prints OK, or the error code and HTTP status. It also requests a missing key to show the 404 or 403, and exits with 1 if a required check fails or 2 if it can’t reach the endpoint. For an S3-compatible provider, set ENDPOINT and REGION. It writes and deletes small objects under PREFIX only.
Untested: we built this from the boto3 documentation (client parameters, error handling, copy_object) and have not run it against AWS or any other provider.
"""Check what an access key can do in one S3 bucket.
Untested: built from the boto3 documentation, not run against AWS or any
S3-compatible service. It creates and deletes small objects under PREFIX.
"""
import sys
import boto3
from botocore.config import Config
from botocore.exceptions import BotoCoreError, ClientError
BUCKET = "<BUCKET>"
REGION = "<REGION>" # the bucket's region, or the region string your provider documents
ENDPOINT = None # AWS: None. S3-compatible: "https://<ENDPOINT>"
ACCESS_KEY = "<ACCESS_KEY_ID>" # the throwaway user's key, never your admin key
SECRET_KEY = "<SECRET_ACCESS_KEY>"
PREFIX = "policy-check/" # scratch folder; for a folder-scoped policy use "<FOLDER>/policy-check/"
s3 = boto3.client(
"s3",
region_name=REGION,
endpoint_url=ENDPOINT,
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
config=Config(
signature_version="s3v4",
s3={"addressing_style": "path" if ENDPOINT else "auto"},
),
)
KEY = PREFIX + "probe.txt"
RENAMED = PREFIX + "probe-renamed.txt"
BIG = PREFIX + "probe-multipart.bin"
upload = {}
def start_multipart():
upload["id"] = s3.create_multipart_upload(Bucket=BUCKET, Key=BIG)["UploadId"]
# (label, required by the minimum policy?, call)
CHECKS = [
("list folder s3:ListBucket", True,
lambda: s3.list_objects_v2(Bucket=BUCKET, Prefix=PREFIX, MaxKeys=1)),
("upload s3:PutObject", True,
lambda: s3.put_object(Bucket=BUCKET, Key=KEY, Body=b"policy check\n")),
("file details s3:GetObject", True,
lambda: s3.head_object(Bucket=BUCKET, Key=KEY)),
("download s3:GetObject", True,
lambda: s3.get_object(Bucket=BUCKET, Key=KEY)["Body"].read()),
("rename: copy s3:GetObject + s3:PutObject", True,
lambda: s3.copy_object(Bucket=BUCKET, Key=RENAMED,
CopySource={"Bucket": BUCKET, "Key": KEY})),
("rename: delete s3:DeleteObject", True,
lambda: s3.delete_object(Bucket=BUCKET, Key=KEY)),
("delete s3:DeleteObject", True,
lambda: s3.delete_object(Bucket=BUCKET, Key=RENAMED)),
("multipart start s3:PutObject", True, start_multipart),
("list parts s3:ListMultipartUploadParts", True,
lambda: s3.list_parts(Bucket=BUCKET, Key=BIG, UploadId=upload["id"])),
("list uploads s3:ListBucketMultipartUploads", True,
lambda: s3.list_multipart_uploads(Bucket=BUCKET, Prefix=PREFIX)),
("multipart abort s3:AbortMultipartUpload", True,
lambda: s3.abort_multipart_upload(Bucket=BUCKET, Key=BIG, UploadId=upload["id"])),
("region lookup s3:GetBucketLocation", False,
lambda: s3.get_bucket_location(Bucket=BUCKET)),
("list buckets s3:ListAllMyBuckets", False,
lambda: s3.list_buckets()),
]
def check(call):
try:
call()
except ClientError as err:
code = err.response["Error"]["Code"]
status = err.response["ResponseMetadata"]["HTTPStatusCode"]
return f"{code} (HTTP {status})"
except KeyError:
return "SKIPPED (no multipart upload was started)"
return "OK"
def main():
failed = 0
try:
for label, required, call in CHECKS:
result = check(call)
note = "" if required else " optional"
print(f"{label:<50} {result}{note}")
if required and result != "OK":
failed += 1
missing = check(lambda: s3.get_object(Bucket=BUCKET, Key=PREFIX + "no-such-key"))
print(f"{'missing key (404 = ListBucket granted)':<50} {missing}")
except BotoCoreError as err:
print(f"Could not reach {ENDPOINT or 'AWS'}: {err}", file=sys.stderr)
return 2
print("All required checks passed." if failed == 0
else f"{failed} required check(s) failed.")
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())With the policy from the first section, you should see OK on every required row, AccessDenied (HTTP 403) on the two optional rows and NoSuchKey (HTTP 404) on the missing key. We expect this from AWS’s documentation and haven’t observed it. If a delete or the abort is denied, remove the leftovers under PREFIX with admin credentials, because AWS charges for an open upload’s parts until it is completed or stopped.
Break it on purpose, then clean up
Remove s3:ListBucket from policy.json and re-run put-user-policy, or edit the inline policy in the console. When you re-run the program, the list row should fail and the missing-key row should change from 404 to 403.
To settle the multipart placement question, move s3:ListBucketMultipartUploads into the ObjectLevel statement and re-run. If the list-uploads row turns into AccessDenied, the action needs the bucket ARN, as the multipart overview says. We haven’t run this test.
A denied call prints HTTP 403, usually as AccessDenied (HTTP 403). For a missing Allow, AWS documents a message that follows the caller’s ARN with “is not authorized to perform: s3:GetObject because no identity-based policy allows the s3:GetObject action” (AWS). That is AWS’s documented pattern; we have no captured output to show.
To clean up with the CLI, delete the access key, then the inline policy, then the user. AWS’s delete-user reference says a programmatic delete fails unless you remove the attached items first:
aws iam delete-access-key --user-name <TEST_USER> --access-key-id <ACCESS_KEY_ID>
aws iam delete-user-policy --user-name <TEST_USER> --policy-name web-client-one-bucket
aws iam delete-user --user-name <TEST_USER>To clean up in the console (AWS):
- On the user’s Security credentials tab, in Access keys, choose Actions, then Deactivate, and confirm. AWS says that if users have active access keys, “you must deactivate the access keys before deleting the users”.
- In Users, select the user’s checkbox and choose Delete. Type the user name and choose Delete. The inline policy is deleted with the user.
Then give the same policy to the user whose key the web client will hold.
R2, B2, Wasabi, MinIO and Spaces scope keys differently
MinIO and Wasabi take AWS-style JSON policies, while R2, B2 and Spaces scope a key through settings you choose when you create it. The test program works against any of them through ENDPOINT.
| Provider | How a key is scoped | Closest to this policy | Watch out for |
|---|---|---|---|
| Cloudflare R2 | API tokens with preset permission levels | Object Read & Write, which allows “read, write, and list objects in specific buckets” | Admin Read & Write can also create, delete and configure buckets; only the Object levels can be scoped to buckets |
| Backblaze B2 | Application keys | A key limited to one bucket, and optionally to a file-name prefix | S3 ListBuckets needs the list-all-bucket-names setting, offered only on single-bucket keys; a prefix key lists only under a prefix at least as restrictive |
| Wasabi | IAM-style JSON policies | Its single-bucket example grants "s3:*"; trim it to this post’s actions |
Its console needs ListAllMyBuckets; a client given the bucket name may not, so test it |
| MinIO | Policies in the AWS IAM policy schema | This post’s policy, created and attached with mc (below) |
arn:aws:s3:::data* also matches the buckets data_private and data_internal, so name the bucket exactly |
| DigitalOcean Spaces | Limited-access keys per bucket | Read/Write/Delete on the one bucket | Limited-access keys are incompatible with PutBucketPolicy bucket policies |
For the CORS side of a browser client on MinIO, see fix CORS errors on a MinIO bucket. MinIO’s multi-user guide, in a community repository archived and read-only since 2026-04-25, creates and attaches a policy like this, with <ALIAS> and <USER> as placeholders:
mc admin policy create <ALIAS> web-client-one-bucket policy.json
mc admin policy attach <ALIAS> web-client-one-bucket --user=<USER>Try Opndrive
Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.
See it on GitHub or read the docs.



