How to get URLs of S3 objects with no expiry date and with public access?

0

I tried some thing :

  1. Block all public access: off
  2.     {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "************/*"
        }```
    

but I'm getting a warning that Publicly accessible with a red color box under my bucket name. Should I worry about that?

OR is there any way to acess some thing like pass /appID to access private objects like: https://bucket.s3.us-north-8.amazonaws.com/img.png/appID

Finally my need is to get URLs of objects that I will hard code in my post model some thing like below: URL attribute will be a string:

type Post @model{
  id: ID!
  title: String!
  fileURL: https://bucket.s3.us-north-8.amazonaws.com/img.png
}

now in future I can't change the URL attribute. So I need a without expire date secure file access

1 個回答
0
已接受的答案

Best practice is to have no publicly-accessible objects. All the "Block Public Access" settings should be on and you should not have any "Publicly accessible" warnings.

If you need to allow people access to objects from their web browser, the two secure options are:

  1. If the objects are assets for a public website, make the bucket a CloudFront origin. Don't use S3's built-in static website hosting (URLs like http://<bucket-name>.s3-website-<region>.amazonaws.com or http://<bucket-name>.s3-website.<region>.amazonaws.com) as it doesn't support http.
  2. If the objects are private then your app should vend presigned URLs providing secure temporary access.

Your URL "https://bucket.s3.us-north-8.amazonaws.com/img.png" looks more like an S3 REST API URL, which would be used from an application either directly or more typically via an API package such as Boto3 for Python. In this case your application would get secure access to S3 objects with IAM credentials.

專家
已回答 1 年前
  • But they mentioned that Amplify.Storage.GetURL is only to download image I want all user can acess my objects. just like other app even if you not loggged in you can access photos ex: twitter, instagram

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南