score:3
There are two things to note:
- Where to assign permissions for access to Amazon S3
- Which permissions to assign
Where to assign permissions for access to Amazon S3
Objects in Amazon S3 are private by default. There are three ways to assign permission to access objects:
- Object ACLs (Access Control Lists): These are permissions on the objects themselves
- Bucket Policies: This is a set of rules applied to the bucket as a whole, but it can also specify permissions related to a subset of a bucket (eg a particular path within the bucket)
- IAM Policies that are applied to IAM Users, Groups or Roles: These permissions apply specifically to those entities
If your intention is to keep the content of the S3 bucket private but allow access to a specific user, then you should assign permissions to the IAM User (as you have done). It also means that you do not require a Bucket Policy since granting access via any one of the above methods is sufficient.
See documentation: Guidelines for Using the Available Access Policy Options
Also a CORS Policy is only required if a HTML page served from one domain is referring to content from another domain. It is quite possible that you do not require the CORS Policy -- do some testing to confirm whether this is the case.
Which permissions to assign
This is always confusing... Some permissions are associated with the Bucket, while some permissions are associated with the contents of the Bucket.
The following permissions from your policy should be at the Bucket level (arn:aws:s3:::MyBucket
):
- s3:CreateBucket
- s3:DeleteBucket
- s3:DeleteBucketPolicy
- s3:GetBucketPolicy
- s3:GetLifecycleConfiguration
- s3:ListBucket
- s3:ListBucketMultipartUploads
- s3:PutBucketPolicy
- s3:PutLifecycleConfiguration
Other API calls (eg GetObject
) should be at the object-level (eg arn:aws:s3:::MyBucket/*
).
See: Specifying Permissions in a Policy
Therefore, the policy associated with your IAM User should look more like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:ListBucket",
"s3:ListBucketVersions",
"s3:ListMultipartUploadParts"
],
"Resource": [
"arn:aws:s3:::MY-BUCKET"
]
},
{
"Sid": "Stmt2",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::MY-BUCKET/*"
]
}
]
}
This grants GetObject
permission to objects within the bucket, rather than on the bucket itself.
score:0
Just if some body will face with the same problem - be sure that all files was uploaded to bucket, because if you use "Add files" button it does not upload nested folders. Better use "drag and drop".
Source: stackoverflow.com
Related Query
- Amazon S3 - Failed to load resource: the server responded with a status of 403 (Forbidden)
- Failed to load resource: the server responded with a status of 431 (Request Header Fields Too Large)
- Failed to load resource: the server responded with a status of 404 (Not Found) in React.js Project deployed
- Failed to load resource: the server responded with a status of 405 (Not Allowed) needs help on nginx.conf
- Failed to load resource: the server responded with a status of 500. Deployed react app with vercel
- Failed to load resource: the server responded with a status of 404 (Not Found) when editing form React Node MySQL
- Faced Failed to load resource: the server responded with a status of 404 () when uploaded my react app to github pages
- "How to fix Failed to load resource: the server responded with a status of 500 in React and express
- IBM-Watson assistant - Failed to load resource: the server responded with a status of 404 (Not Found)
- React app Failed to load resource: the server responded with a status of 404
- Failed to load resource: the server responded with a status of 400 () React.js
- SCORM Failed to load resource: the server responded with a status of 404 ()
- React app failed to load resource: the server responded with a status of 404 GraphQL
- Amplify makes `Failed to load resource: the server responded with a status of 400` error
- Deploying a Node.js React App, on CPanel - 'Failed to load resource: the server responded with a status of 404 ()'
- "Failed to load resource: the server responded with a status of 404 (Not Found)" + "Origin … is not allowed by Access-Control-Allow-Origin."
- how solve this error (Failed to load resource: the server responded with a status of 404 ())
- React-Failed to load resource: the server responded with a status of 400 (Bad Request)
- React proxy, the server responded with a status of 404 (Not Found)
- Error: Hydration failed because the initial UI does not match what was rendered on the server with useSession() and react-bootstrap
- electron & react: No resource with given URL found, DevTools failed to load SourceMap
- reactJS app with a fetch to an API fails to load with No 'Access-Control-Allow-Origin' header is present on the requested resource
- Reactjs how to call magento 2 api with bearer (the server responded with a status of 401 (unauthorized))
- No 'access-control-allow-origin' header is present on the requested resource With Resource Server in Spring Boot
- Server returns status 403 forbidden when i send request with bearer token
- ReactJS + ServerSide with ExpressJS - need a way to dictate what to load on the server vs client
- Error: Request failed with status code 400. Differences between sending in POSTMAN and in the application
- Error: Request failed with status code 403 - Problem with Axios, possible exchange for fetch
- Uable to make a req from one server to another - "Error: Request failed with status code 401"
- Why I get "the server responded with a status of 404 " for remixicon.woff2 with reactJs?
More Query from same tag
- Save each index into each button
- State was undefined for like 0.3s and then got data from API
- Unexpected state behaviour while dynamically rendering elements in React typescript
- Is It Possible To Trigger Contained Component's render from within the Container in React?
- Where should the enzyme setup file be written?
- How to map over an array that is fetched using axios
- I try to inject React.createContext Api into Thunk withExtraArgument but don't understand something
- React and React Router DOM - NavLink and Link aren't triggering API based OAuth flow
- How to pass the 'onClick' function to child component in React
- TinyMCE editor with React Cannot access local files
- Remove dependency on sequential id values in React code
- VSCode keeps asking to import React on NextJS and React 17 apps
- How use forwarded ref and internal ref simultaneously in React
- How to fetch data an array instead of an object in JS?
- State was mutated as a side effect?
- Material UI Dialog not working in production - shows a blank page
- Vite and Sendbird does not works
- Adding parent div's inside .map
- Proper mock function for multiple tests inside component
- Why React callback bind to null works?
- Adding and deleting array of classes error
- Getting an empty array in React while fetching the data from the api
- Div not showing but numbers in React
- How to create a React component in TypeScript that lets me handle an event?
- Integrating Dispatch Actions in Container Component Pattern
- Formik not displaying on a nextjs page?
- How do I use Config Vars in Heroku to get my API key to work?
- Openlayers GeoJSON is at the wrong place
- RxDB - Use the existing local DB
- Websocket server and npm start on localhost