View Source AWS.Client (aws-elixir v0.13.1)

Provides credentials and connection details for making requests to AWS services.

You can configure access_key_id and secret_access_key which are the credentials needed by IAM, and also the region for your services. The list of regions can be found in the AWS service endpoints documentation. You can also use "local" to make requests to your localhost.


Custom HTTP client

The option http_client accepts a tuple with a module and a list of options. The module must implement the callback AWS.HTTPClient.request/5.


Custom JSON or XML parsers

You can configure a custom JSON parser by using the option json_module. This option accepts a tuple with a module and options. The given module must implement the callbacks from AWS.JSON.

Similarly, there is a xml_module option that configures the XML parser. The XML module must implement the callbacks from AWS.XML.


Additional options

  • :session_token - an option to set the X-Amz-Security-Token when performing the requests.
  • :port - is the port to use when making requests. Defaults to 443.
  • :proto - is the protocol to use. It can be "http" or "https". Defaults to "https".
  • :endpoint - the AWS endpoint. Defaults to "". You can configure this using put_endpoint/2 for AWS compatible APIs.

The service option is overwritten by each service with its signing name from metadata.

Link to this section Summary


The endpoint configuration.


Link to this section Types

@type endpoint_config() ::
  binary() | {:keep_prefixes, binary()} | (map() -> binary()) | nil

The endpoint configuration.

Check put_endpoint/2 for more details.

@type t() :: %AWS.Client{
  access_key_id: binary() | nil,
  endpoint: endpoint_config(),
  http_client: {module(), keyword()},
  json_module: {module(), keyword()},
  port: non_neg_integer(),
  proto: binary(),
  region: binary() | nil,
  secret_access_key: binary() | nil,
  service: binary() | nil,
  session_token: binary() | nil,
  xml_module: {module(), keyword()}

Link to this section Functions

Link to this function

create(access_key_id, secret_access_key, region)

View Source
Link to this function

create(access_key_id, secret_access_key, token, region)

View Source
Link to this function

decode!(client, payload, format)

View Source

The default endpoint.

Check put_endpoint/2 for more details on how to configure a custom endpoint.

Link to this function

encode!(client, payload, format)

View Source
Link to this function

put_endpoint(client, endpoint_config)

View Source

Configures the endpoint to a custom one.

This is useful to set a custom endpoint when working with AWS compatible APIs. The following configuration is valid:

  • "": this will be used as it is, without considering regions or endpoint prefixes or account id.

  • {:keep_prefixes, ""}: it will keep the same rules from AWS to build the prefixes. For example, if region is "us-east-1" and the service prefix is "s3", then the final endpoint will be ""

  • fn options -> "" end: a function that will be invoked with options for that request. options is a map with the following shape:

        endpoint: endpoint_config(),
        region: binary() | nil,
        service: binary(),
        global?: boolean(),
        endpoint_prefix: binary(),
        account_id: binary() | nil



iex> put_endpoint(%Client{}, "")
%Client{endpoint: "}

iex> put_endpoint(%Client{}, {:keep_prefixes, ""})
%Client{endpoint: {:keep_prefixes, "}}

iex> put_endpoint(%Client{}, fn opts -> Enum.join(["baz", opts.region, ""], ".") end)
%Client{endpoint: #Function<>}
Link to this function

request(client, method, url, body, headers, opts \\ [])

View Source