Skip to content

A terraform module to reliably get my ip (v4 and/or v6) even when some services could fail or give wrong answers.

License

Notifications You must be signed in to change notification settings

atrull/terraform-overbuilt-getmyip

Repository files navigation

Overbuilt myip module

What it does

This module polls a series of fairly well known but occasionally unreliable 'what is my ip' services. It then produces the most common response that is a valid ipv4 or ipv6 address (both outputs are separately provided).

Requirements

Name Version
terraform ~> 1.0
curl2 ~> 1.6
external ~> 2.3.1
http ~> 3

Providers

Name Version
curl2 1.6.1
external 2.3.1
http 3.4.0

Modules

No modules.

Resources

Name Type
curl2_curl2.myip data source
external_external.external_curl data source
http_http.myip data source

Inputs

Name Description Type Default Required
data_provider curl2 or http providers are also supported - we recommend external_curl because it handles failure better string "external_curl" no
extra_service_urls Put your own in here if you want extra ones, this gets merged with the service_urls list list(string) [] no
request_timeout Request timeout in milliseconds number 500 no
retry_attempts Request retries number 1 no
service_urls List of urls to use for getting our IP list(string)
[
"https://api.seeip.org",
"https://ipinfo.io/ip",
"https://ifconfig.co",
"https://icanhazip.com",
"https://api.ipify.org",
"https://ifconfig.me",
"https://ipecho.net/plain",
"https://ifconfig.io",
"https://ident.me",
"https://ipv4.ident.me"
]
no

Outputs

Name Description
ipv4 The most common ipv4 response
ipv4_all_matches List of all the ipv4 matches (informational/testing)
ipv6 The most common ipv6 response
ipv6_all_matches List of all the ipv6 matches (informational/testing)

Providers and their Limitations : An explanation.

The goal of this module is to provide a valid-enough answer even when the internet does what the internet does, which is to be flaky and broken somewhere, sometime.

Neither the curl2 nor http providers are perfectly suited to the internet since they will fail a run if the url doesn't respond and/or the url doesn't resolve. The curl2 provider is slightly more reliable than the http provider. This failure mode makes sense if it's a critical part of your terraform..

Both of curl2 and http providers are provided as a matter of them being possibly better in the future if/when they have some ignore_failure options.

Since we're aggregating results to achieve a 'most common' response it frankly shouldn't matter if one of the endpoints in the list fails to respond - we will have gathered enough data to make a good response. Let the build roll on!

As such we implement an external_curl using the external provider and a shim script external_curl.sh, which will survive a truly non-resolving non-responsive endpoint by faking the response data, which will be filtered out later by our ipv4_matches and ipv6_matches filters.

Authors

Alex Trull ([email protected])

License

BSD-3

Inspiration

The failed builds because the myip service I had chosen wasn't working or there was a routing error in the pipeline. I owe it all to you!

Additional information for users from all ip addresses

  • I am very fond of you all.

About

A terraform module to reliably get my ip (v4 and/or v6) even when some services could fail or give wrong answers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published