rabbitmq-server/deps/rabbitmq_aws
Loïc Hoguin c5d150a7ef
Use Erlang.mk's native Elixir support for CLI
This avoids using Mix while compiling which simplifies
a number of things and let us do further build improvements
later on.

Elixir is only enabled from within rabbitmq_cli currently.

Eunit is disabled since there are only Elixir tests.

Dialyzer will force-enable Elixir in order to process
Elixir-compiled beam files.

This commit also includes a few changes that are
related:

 * The Erlang distribution will now be started for parallel-ct

 * Many unnecessary PROJECT_MOD lines have been removed

 * `eunit_formatters` has been removed, it provides little value

 * The new `maybe_flock` Erlang.mk function is used where possible

 * Build test deps when testing rabbitmq_cli (Mix won't do it anymore)

 * rabbitmq_ct_helpers now use the early plugins to have Dialyzer
   properly set up
2025-03-18 10:02:49 +01:00
..
include Bump (c) line year 2025-01-01 17:54:10 -05:00
priv/schema Bump (c) line year 2025-01-01 17:54:10 -05:00
src Handle empty HTTP body in response (as some AWS 200 reponse will have an empty body for some reason) 2024-07-15 22:59:20 +00:00
test Remove unused imports (thanks elp!) 2024-05-23 16:36:08 +02:00
.editorconfig Add minimal API documentation to the README 2016-05-19 16:19:29 -04:00
.gitignore Cleanup .gitignore files for the monorepo 2024-06-28 12:00:52 +02:00
LICENSE Fix query arg encoding 2016-05-23 21:17:00 -04:00
LICENSE-erlcloud Fix query arg encoding 2016-05-23 21:17:00 -04:00
LICENSE-httpc_aws Fix query arg encoding 2016-05-23 21:17:00 -04:00
LICENSE-rabbitmq_aws Fix query arg encoding 2016-05-23 21:17:00 -04:00
Makefile Use Erlang.mk's native Elixir support for CLI 2025-03-18 10:02:49 +01:00
README.md make: Remove Travis-specific targets/config 2024-06-24 14:12:02 +02:00
rabbitmq_aws.iml Revert "Correct a double quote introduced in #4603" 2022-04-20 16:05:56 +04:00

README.md

rabbitmq-aws

A fork of gmr/httpc-aws for use in building RabbitMQ plugins that interact with Amazon Web Services APIs.

Supported Erlang Versions

Same as RabbitMQ

Configuration

Configuration for rabbitmq-aws is can be provided in multiple ways. It is designed to behave similarly to the AWS Command Line Interface with respect to providing region and configuration information. Additionally it has two methods, rabbitmq_aws:set_region/1 and rabbitmq_aws:set_credentials/2 to allow for application specific configuration, bypassing the automatic configuration behavior.

Configuration Precedence

The configuration values have the following precedence:

  • Explicitly configured via API
  • Environment variables
  • Configuration file
  • EC2 Instance Metadata Service where applicable

Credentials Precedence

The credentials values have the following precedence:

  • Explicitly configured via API
  • Environment variables
  • Credentials file
  • EC2 Instance Metadata Service

EC2 Instance Metadata Service Versions

There are two versions of the EC2 Instance Metadata Service (IMDS) that are available by default on EC2 instances; IMDSv1 and IMDSv2 which is protected by session authentication and adds defenses against additional vulnerabilities. AWS recommends adopting IMDSv2 and disabling IMDSv1 by configuring the Instance Metadata Service on the EC2 instances.

By default rabbitmq-aws will attempt to use IMDSv2 first and will fallback to use IMDSv1 if calls to IMDSv2 fail. This behavior can be overridden by setting the aws.prefer_imdsv2 setting to false.

Environment Variables

As with the AWS CLI, the following environment variables can be used to provide configuration or to impact configuration behavior:

  • AWS_DEFAULT_PROFILE
  • AWS_DEFAULT_REGION
  • AWS_CONFIG_FILE
  • AWS_SHARED_CREDENTIALS_FILE
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

API Functions

Method Description
rabbitmq_aws:set_region/1 Manually specify the AWS region to make requests to.
rabbitmq_aws:set_credentials/2 Manually specify the request credentials to use.
rabbitmq_aws:refresh_credentials/0 Refresh the credentials from the environment, filesystem, or EC2 Instance Metadata Service.
rabbitmq_aws:ensure_imdsv2_token_valid/0 Make sure EC2 IMDSv2 token is active and valid.
rabbitmq_aws:api_get_request/2 Perform an AWS service API request.
rabbitmq_aws:get/2 Perform a GET request to the API specifying the service and request path.
rabbitmq_aws:get/3 Perform a GET request specifying the service, path, and headers.
rabbitmq_aws:post/4 Perform a POST request specifying the service, path, headers, and body.
rabbitmq_aws:request/5 Perform a request specifying the service, method, path, headers, and body.
rabbitmq_aws:request/6 Perform a request specifying the service, method, path, headers, body, and httpc:http_options().
rabbitmq_aws:request/7 Perform a request specifying the service, method, path, headers, body, httpc:http_options(), and override the API endpoint.

Example Usage

The following example assumes that you either have locally configured credentials or that you're using the EC2 Instance Metadata Service for credentials:

application:start(rabbitmq_aws).
{ok, {Headers, Response}} = rabbitmq_aws:get("ec2","/?Action=DescribeTags&Version=2015-10-01").

To configure credentials, invoke rabbitmq_aws:set_credentials/2:

application:start(rabbitmq_aws).

rabbitmq_aws:set_credentials("AKIDEXAMPLE", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"),

RequestHeaders = [{"Content-Type", "application/x-amz-json-1.0"},
                  {"X-Amz-Target", "DynamoDB_20120810.ListTables"}],
                  
{ok, {Headers, Response}} = rabbitmq_aws:post("dynamodb", "/", 
                                              "{\"Limit\": 20}",
                                              RequestHeaders).

Build

make

Test

make tests

License

BSD 3-Clause License