Amazon AWS S3 Public bucket

Hello guys I am doing the course Liveview course of the pragprog and I would like to know how to put the Amazon AWS S3 bucket to be public.

I created the bucket and put the ‘CORS’ on the ‘Permissions’.
But I can’t put this new bucket on public.
Someone could help me with this please?

My application is complaining for this:

[error] GenServer #PID<0.713.0> terminating
** (FunctionClauseError) no function clause matching in RldLiveViewStudioWeb.DesksLive.error_to_string/1
    (rld_live_view_studio 0.1.0) lib/rld_live_view_studio_web/live/desks_live.ex:74: RldLiveViewStudioWeb.DesksLive.error_to_string(:external_client_failure)
    (rld_live_view_studio 0.1.0) lib/rld_live_view_studio_web/live/desks_live.html.heex:49: anonymous fn/3 in RldLiveViewStudioWeb.DesksLive.render/1
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:398: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:544: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.14.3) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:396: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:571: anonymous fn/3 in Phoenix.LiveView.Diff.traverse_comprehension/5
    (elixir 1.14.3) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:484: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:571: anonymous fn/3 in Phoenix.LiveView.Diff.traverse_comprehension/5
    (elixir 1.14.3) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.14.3) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.14.3) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:450: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:544: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.14.3) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:373: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:544: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.14.3) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:373: Phoenix.LiveView.Diff.traverse/7
Last message: %Phoenix.Socket.Message{topic: "lv:phx-F5alJ2XuJWOBaQGj", event: "progress", payload: %{"entry_ref" => "0", "event" => nil, "progress" => %{"error" => "failed"}, "ref" => "phx-F5alJ5A-iS4F6QMC"}, ref: "11", join_ref: "4"}
State: %{components: {%{}, %{}, 1}, join_ref: "4", serializer: Phoenix.Socket.V2.JSONSerializer, socket: #Phoenix.LiveView.Socket<id: "phx-F5alJ2XuJWOBaQGj", endpoint: RldLiveViewStudioWeb.Endpoint, view: RldLiveViewStudioWeb.DesksLive, parent_pid: nil, root_pid: #PID<0.713.0>, router: RldLiveViewStudioWeb.Router, assigns: %{__changed__: %{}, flash: %{}, form: %Phoenix.HTML.Form{source: #Ecto.Changeset<action: :validate, changes: %{name: "Wally"}, errors: [], data: #RldLiveViewStudio.Desks.Desk<>, valid?: true>, impl: Phoenix.HTML.FormData.Ecto.Changeset, id: "desk", name: "desk", data: %RldLiveViewStudio.Desks.Desk{__meta__: #Ecto.Schema.Metadata<:built, "desks">, id: nil, name: nil, photo_locations: [], inserted_at: nil, updated_at: nil}, hidden: [], params: %{"name" => "Wally"}, errors: [], options: [method: "post"], index: nil, action: nil}, live_action: nil, streams: %{__changed__: MapSet.new([]), desks: %Phoenix.LiveView.LiveStream{name: :desks, dom_id: #Function<3.113057034/1 in Phoenix.LiveView.LiveStream.new/3>, inserts: [], deletes: []}}, uploads: %{__phoenix_refs_to_names__: %{"phx-F5alJ5A-iS4F6QMC" => :photos}, photos: #Phoenix.LiveView.UploadConfig<name: :photos, max_entries: 3, max_file_size: 10000000, entries: [%Phoenix.LiveView.UploadEntry{progress: 0, preflighted?: true, upload_config: :photos, upload_ref: "phx-F5alJ5A-iS4F6QMC", ref: "0", uuid: "82a6de32-406d-49cd-97e7-fc524021a170", valid?: true, done?: false, cancelled?: false, client_name: "bingo01.jpg", client_relative_path: "", client_size: 47293, client_type: "image/jpeg", client_last_modified: 1679089898580}], accept: ".png,.jpeg,.jpg", ref: "phx-F5alJ5A-iS4F6QMC", errors: [], auto_upload?: false, progress_event: nil, ...>}}, transport_pid: #PID<0.707.0>, ...>, topic: "lv:phx-F5alJ2XuJWOBaQGj", upload_names: %{photos: {"phx-F5alJ5A-iS4F6QMC", nil}}, upload_pids: %{}}

But I changed the name of the @s3_bucketto use an old bucket I have then it work’s!
But I would like to know how to deal with a new bucket.
for others apps.

Are you trying to make your AWS bucket public? If yes, you can simply change it here with the edit button.

I tried there before but it was unsuccessfully.
Which options you put?

After setting it to public, you can update the bucket policy to allow read and write access.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Allow",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<user_iam_id>:user/<bucketname>"
            },
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::<bucketname>/*",
                "arn:aws:s3:::<bucketname>"
            ]
        },
        {
            "Sid": "AllowAllRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": [
                "arn:aws:s3:::<bucketname>/*",
                "arn:aws:s3:::<bucketname>"
            ]
        }
    ]
}
1 Like