IMDS.Providers.Azure (imds v1.0.0)

Copy Markdown

Azure Instance Metadata Service (IMDS).

Every request sends Metadata: true. Requests use API version 2021-02-01 unless the :api_version option gives another value. request/3 adds the api-version query parameter when the path does not hold one. The raw identity map contains the complete Azure metadata document, including the network fields.

Summary

Functions

Return the API version used for requests.

Return the metadata path of the API version in opts.

Return the first private IPv4 address in an Azure metadata document.

Functions

api_version(opts)

@spec api_version(keyword()) :: binary()

Return the API version used for requests.

path(opts \\ [])

@spec path(keyword()) :: binary()

Return the metadata path of the API version in opts.

Examples

iex> IMDS.Providers.Azure.path([])
"/metadata/instance?api-version=2021-02-01&format=json"

iex> IMDS.Providers.Azure.path()
"/metadata/instance?api-version=2021-02-01&format=json"

private_ipv4(document)

@spec private_ipv4(map()) :: binary() | nil

Return the first private IPv4 address in an Azure metadata document.

Examples

iex> document = %{"network" => %{"interface" => [%{"ipv4" => %{"ipAddress" => [%{"privateIpAddress" => "10.0.0.4"}]}}]}}
iex> IMDS.Providers.Azure.private_ipv4(document)
"10.0.0.4"

iex> IMDS.Providers.Azure.private_ipv4(%{})
nil