Skip to content

Instantly share code, notes, and snippets.

@evadne
Created September 12, 2019 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evadne/2ee20284206eaab406e36c22a9ef0bf3 to your computer and use it in GitHub Desktop.
Save evadne/2ee20284206eaab406e36c22a9ef0bf3 to your computer and use it in GitHub Desktop.
ExAws add-on for AWS Service Discovery
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