Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExAWS.S3.list_buckets() fails when virtual_host is set to true #1119

Open
Xe opened this issue Feb 11, 2025 · 0 comments
Open

ExAWS.S3.list_buckets() fails when virtual_host is set to true #1119

Xe opened this issue Feb 11, 2025 · 0 comments

Comments

@Xe
Copy link

Xe commented Feb 11, 2025

Hello,

I'm trying to write some example code to list all S3 buckets when using virtual hosting mode and I'm running into a strange issue. This code causes nxdomain errors:

defmodule ListAllBucketsTest do
  use ExUnit.Case

  test "list all buckets" do
    response = ExAws.S3.list_buckets() |> ExAws.request!()

    if response.status_code == 200 do
      IO.puts("Buckets:")

      for bucket <- response.body.buckets do
        IO.puts(bucket.name)
      end
    else
      IO.puts("Error listing buckets")
    end
  end
end

Here is my config/config.exs file:

import Config

config :ex_aws,
  debug_requests: true,
  json_codec: Jason,
  access_key_id: {:system, "AWS_ACCESS_KEY_ID"},
  secret_access_key: {:system, "AWS_SECRET_ACCESS_KEY"}

config :ex_aws, :s3,
  scheme: "https://",
  host: "s3.amazonaws.com",
  region: "us-east-1",
  virtual_host: true

This throws errors like this:

12:44:07.729 [debug] ExAws: Request URL: "https://.s3.amazonaws.com/" HEADERS: [{"Authorization", "AWS4-HMAC-SHA256 Credential=hunter2"}, {"host", ".s3.amazonaws.com"}, {"x-amz-date", "20250211T174407Z"}, {"x-amz-content-sha256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}] BODY: "" ATTEMPT: 7

Disabling virtual host style requests makes this test work.

Xe added a commit to tigrisdata/tigris-os-docs that referenced this issue Feb 11, 2025
Xe added a commit to tigrisdata/tigris-os-docs that referenced this issue Feb 11, 2025
Xe added a commit to tigrisdata/tigris-os-docs that referenced this issue Feb 11, 2025
Xe added a commit to tigrisdata/tigris-os-docs that referenced this issue Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant