A Terraform provider for a data source to get an external IP
Switch branches/tags
Clone or download
Latest commit 4a99f6a Jun 21, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples initial commit Jun 21, 2018
extip initial commit Jun 21, 2018
scripts initial commit Jun 21, 2018
vendor Add Vendor Folder Jun 21, 2018
.gitignore initial commit Jun 21, 2018
.travis.yml initial commit Jun 21, 2018
CHANGELOG.md initial commit Jun 21, 2018
GNUmakefile initial commit Jun 21, 2018
LICENSE Create LICENSE Jun 21, 2018
README.md Add Travis Badge Jun 21, 2018
main.go initial commit Jun 21, 2018

README.md

terraform-provider-extip

Build Status

Terraform provider for getting your current external IP as a data source.

Requirements

  • Terraform 0.11.x
  • Go 1.10 (to build the provider plugin)

Installing the Provider

Follow the instructions to install it as a plugin. After placing it into your plugins directory, run terraform init to initialize it.

Usage

data "extip" "external_ip" {
}

output "external_ip" {
  value = "${data.extip.external_ip.ipaddress}"
}

Gives the result:

data.extip.external_ip: Refreshing state...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

external_ip = 238.209.109.16

You can also specify what resolver you want to use to get the URL:

data "extip" "external_ip_from_aws" {
  resolver = "https://checkip.amazonaws.com/"
}

output "external_ip_from_aws" {
  value = "${data.extip.external_ip_from_aws.ipaddress}"
}

Examples are under /examples.

Building the Provider

Clone and build the repository

go get github.com/petems/terraform-provider-extip
make build

Symlink the binary to your terraform plugins directory:

ln -s $GOPATH/bin/terraform-provider-extip ~/.terraform.d/plugins/

Updating the Provider

go get -u github.com/petems/terraform-provider-extip
make build

TODO

  • Add configuration of the consensus timing (ie. how long it will wait to resolve)
  • Add option of getting ipv6 or ipv4 ipaddress

Contributing

  • Install project dependencies: go get github.com/kardianos/govendor
  • Run tests: make test
  • Build the binary: make build