diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e7d1f324..555bf3814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ IMPROVEMENTS: [GH-1567] * credential/aws-ec2: Added a new constraint, 'bound_account_id' to the role [GH-1523] + * physical/etcd: Support `ETCD_ADDR` env var for specifying addresses [GH-1576] * secret/aws: Listing of roles is supported now [GH-1546] * secret/mssql,mysql,postgresql: Reading of connection settings is supported in all the sql backends [GH-1515] diff --git a/physical/etcd.go b/physical/etcd.go index 4bb368aac..4f88182d8 100644 --- a/physical/etcd.go +++ b/physical/etcd.go @@ -89,6 +89,10 @@ func newEtcdBackend(conf map[string]string, logger *log.Logger) (Backend, error) if address, ok := conf["address"]; ok { machines = address } + machinesEnv := os.Getenv("ETCD_ADDR") + if machinesEnv != "" { + machines = machinesEnv + } machinesParsed := strings.Split(machines, EtcdMachineDelimiter) // Verify that the machines are valid URLs diff --git a/physical/etcd_test.go b/physical/etcd_test.go index f39312486..36ca26e8c 100644 --- a/physical/etcd_test.go +++ b/physical/etcd_test.go @@ -46,10 +46,11 @@ func TestEtcdBackend(t *testing.T) { } }() + // Generate new etcd backend. The etcd address is read from ETCD_ADDR. No + // need to provide it explicitly. logger := log.New(os.Stderr, "", log.LstdFlags) b, err := NewBackend("etcd", logger, map[string]string{ - "address": addr, - "path": randPath, + "path": randPath, }) if err != nil { t.Fatalf("err: %s", err) diff --git a/website/source/docs/commands/environment.html.md b/website/source/docs/commands/environment.html.md index 928d2d9ee..bbc9f48eb 100644 --- a/website/source/docs/commands/environment.html.md +++ b/website/source/docs/commands/environment.html.md @@ -9,7 +9,7 @@ description: |- # Environment variables The Vault CLI will read the following environment variables to set -behavioral defaults. These can be overridden in all cases using +behavioral defaults. These can be overridden in all cases using command-line arguments; see the command-line help for details. The following table describes them: diff --git a/website/source/docs/config/index.html.md b/website/source/docs/config/index.html.md index ad43fc0f5..0e576675f 100644 --- a/website/source/docs/config/index.html.md +++ b/website/source/docs/config/index.html.md @@ -331,7 +331,8 @@ For etcd, the following options are supported: * `address` (optional) - The address(es) of the etcd instance(s) to talk to. Can be comma separated list (protocol://host:port) of many etcd instances. - Defaults to "http://localhost:2379" if not specified. + Defaults to "http://localhost:2379" if not specified. May also be specified + via the ETCD_ADDR environment variable. * `sync` (optional) - Should we synchronize the list of available etcd servers on startup? This is a **string** value to allow for auto-sync to @@ -473,7 +474,7 @@ profile enabled. Vault will handle renewing profile credentials as they rotate. * `max_parallel` (optional) - The maximum number of concurrent connections to Azure. Defaults to "128". -The current implementation is limited to a maximum of 4 MBytes per blob/file. +The current implementation is limited to a maximum of 4 MBytes per blob/file. #### Backend Reference: Swift (Community-Supported)