Listing S3 objects with Elixir

Using ExAWS library & Elixir to interact with S3

Using ExAWS library to interact with AWS S3. The setup steps is given in the library's documentation.

It returns a map with all the objects listed. Used Jason to convert the returned map to JSON data. You can also loop through the contents using Enum.map.

defmodule ElixirS3 do def list_objects() do {:ok, data} = ExAws.S3.list_objects("links-data") |> ExAws.request() jsonData = data.body.contents |> Enum.map(fn x -> %{key: x.key} end) # Just getting the `key` from objects |> Jason.encode!() File.write!("./data.json", jsonData) end end ElixirS3.list_objects()

There's also aws-elixir library to work with AWS.

Made with love by aayushmau5