Exaws to get aws: Listing objects in bucket

I need to list all objects in my bucket, but it’s giving me an error, here’s the code:

iex(1)> client = AWS.Client.create("access_key_id", "secret_access_key", "us-east-1")
iex(2)> AWS.S3.list_objects_v2(client, "my_bucket")
{:error,
 {:unexpected_response,
  %{
    body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>DXEMX3JVRPJYXKQW</RequestId>
...
...
      {"Server", "AmazonS3"}
    ],
    status_code: 403
  }}}

The status_code: 403 bit in the response shows you that the issue there is authentication. AWS should return 403 when you’re authenticated but you don’t have access to the resource you’re requesting (the AWS bucket in this case).

Can you list the objects in the bucket by using awscli?

1 Like

no , using script in iex

Not sure I follow, I’m sorry. I’d recommend making sure authentication is right and that you can access files with awscli. If that doesn’t work, then the problem would likely not be ExAws, but indeed credentials.

Yes, the problems was credentials