ex-aws / ex_aws

A flexible, easy to use set of clients AWS APIs for Elixir
https://hex.pm/packages/ex_aws
MIT License
1.27k stars 526 forks source link

Config creation ignores region settings #828

Open ewestern opened 2 years ago

ewestern commented 2 years ago

Environment

Erlang/OTP 24 [erts-12.0.4] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit]

Elixir 1.12.2 (compiled with Erlang/OTP 24)

I would expect a Config like:

%{
  access_key_id: "XXXX",
  host: "s3.us-west-1.amazonaws.com",
  http_client: ExAws.Request.Hackney,
  json_codec: Jason,
  normalize_path: true,
  port: 443,
  region: "us-west-1",
  retries: [max_attempts: 10, base_backoff_in_ms: 10, max_backoff_in_ms: 10000],
  role_arn: "arn:aws:iam::XXXXX:role/xxxxx,
  role_session_name: "pfrance",
  scheme: "https://",
  secret_access_key: "XXXXXX",
  security_token: "XXXXX",
  source_profile: "default"
}

Expected behavior

In fact, the config created is:

%{
  access_key_id: "XXXX",
  host: "s3.us-west-1.amazonaws.com",
  http_client: ExAws.Request.Hackney,
  json_codec: Jason,
  normalize_path: true,
  port: 443,
  region: "us-east-2",
  retries: [max_attempts: 10, base_backoff_in_ms: 10, max_backoff_in_ms: 10000],
  role_arn: "arn:aws:iam::XXXX:role/xxxxxr",
  role_session_name: "pfrance",
  scheme: "https://",
  secret_access_key: "XXXX",
  security_token: "XXXX",
  source_profile: "default"
}

This prevents successful actions against S3 resources in non-us-east-2 regions.

bernardd commented 2 years ago

Yep, this is a known issue - there was an attempt to fix it not so long ago over in #796, but it turns out to be more complex. I'd welcome a PR if anyone has the time to address it.

tomjakubowski commented 2 years ago

Just a note for other readers, same bug as #521. That one has a more complete description of the problem, that it involves profiles configured in ~/.aws/config with a region