Created
September 12, 2019 20:34
-
-
Save evadne/2ee20284206eaab406e36c22a9ef0bf3 to your computer and use it in GitHub Desktop.
ExAws add-on for AWS Service Discovery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExAws.ServiceDiscovery do | |
@moduledoc """ | |
Minimal module to issue AWS Cloud Map requests with ExAws, which | |
is used by clustering mechanisms. | |
""" | |
alias ExAws.Operation.JSON | |
@version "2017-03-14" | |
@namespace "Route53AutoNaming_v20170314" | |
def list_instances(service_id) do | |
request(%{ | |
"Action" => "ListInstances", | |
"ServiceId" => service_id | |
}) | |
end | |
defp request(%{"Action" => action} = params, opts \\ %{}) do | |
headers = [ | |
{"x-amz-target", "#{@namespace}.#{action}"}, | |
{"content-type", "application/x-amz-json-1.1"} | |
] | |
params = Map.merge(params, %{"Version" => @version}) | |
body = %{data: params, headers: headers} |> Map.merge(opts) | |
JSON.new(:servicediscovery, body) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment