2017-06-21 08:40:38 +00:00
|
|
|
# Go Discover Nodes for Cloud Providers
|
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
`go-discover` is a Go (golang) library and command line tool to discover
|
|
|
|
ip addresses of nodes in cloud environments based on meta information
|
|
|
|
like tags provided by the environment.
|
2017-06-21 08:40:38 +00:00
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
The configuration for the providers is provided as a list of `key=val
|
|
|
|
key=val ...` tuples where the values can be URL encoded. The provider is
|
|
|
|
determined through the `provider` key. Effectively, only spaces have to
|
|
|
|
be encoded with a `+` and on the command line you have to observe
|
|
|
|
quoting rules with your shell.
|
2017-06-21 08:40:38 +00:00
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
### Example
|
2017-06-21 08:40:38 +00:00
|
|
|
|
|
|
|
```
|
2017-06-22 10:46:23 +00:00
|
|
|
# Amazon AWS
|
|
|
|
provider=aws region=eu-west-1 tag_key=consul tag_value=... access_key_id=... secret_access_key=...
|
|
|
|
|
|
|
|
# Google Cloud
|
|
|
|
provider=gce project_name=... zone_pattern=eu-west-* tag_value=consul credentials_file=...
|
|
|
|
|
|
|
|
# Microsoft Azure
|
|
|
|
provider=azure tag_name=consul tag_value=... tenant_id=... client_id=... subscription_id=... secret_access_key=...
|
2017-06-21 08:40:38 +00:00
|
|
|
```
|
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
### Supported Providers
|
|
|
|
|
|
|
|
The following cloud providers are supported but additional providers
|
|
|
|
can be added to the `discover.Disoverers` map.
|
|
|
|
|
|
|
|
* Amazon AWS [Config options](http://godoc.org/github.com/hashicorp/go-discover/aws)
|
|
|
|
* Google Cloud [Config options](http://godoc.org/github.com/hashicorp/go-discover/gce)
|
|
|
|
* Microsoft Azure [Config options](http://godoc.org/github.com/hashicorp/go-discover/azure)
|
2017-06-21 08:40:38 +00:00
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
## Command Line Tool Usage
|
|
|
|
|
|
|
|
Install the command line tool with:
|
2017-06-21 08:40:38 +00:00
|
|
|
|
|
|
|
```
|
2017-06-22 10:46:23 +00:00
|
|
|
go get -u github.com/hashicorp/go-discover/cmd/discover
|
2017-06-21 08:40:38 +00:00
|
|
|
```
|
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
Then run it with:
|
2017-06-21 08:40:38 +00:00
|
|
|
|
|
|
|
```
|
2017-06-22 10:46:23 +00:00
|
|
|
$ discover provider=aws region=eu-west-1 ...
|
2017-06-21 08:40:38 +00:00
|
|
|
```
|
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
## Library Usage
|
|
|
|
|
|
|
|
Install the library with:
|
2017-06-21 08:40:38 +00:00
|
|
|
|
|
|
|
```
|
2017-06-22 10:46:23 +00:00
|
|
|
go get -u github.com/hashicorp/go-discover
|
2017-06-21 08:40:38 +00:00
|
|
|
```
|
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
Then call the `discover.Discover` function with the arguments
|
|
|
|
for the provider you want to use:
|
2017-06-21 08:40:38 +00:00
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
# use ioutil.Discard for no log output
|
2017-06-21 08:40:38 +00:00
|
|
|
l := log.New(os.Stderr, "", log.LstdFlags)
|
2017-06-22 10:46:23 +00:00
|
|
|
args := "provider=aws region=eu-west-1 ..."
|
|
|
|
addrs, err := discover.Discover(args, l)
|
2017-06-21 08:40:38 +00:00
|
|
|
```
|
|
|
|
|
2017-06-22 10:46:23 +00:00
|
|
|
For complete API documentation, see [GoDoc](https://godoc.org/github.com/hashicorp/go-discover) and
|
|
|
|
the [supported providers](http://godoc.org/github.com/hashicorp/go-discover#pkg-subdirectories).
|
2017-06-21 08:40:38 +00:00
|
|
|
|