diff --git a/command/connect/envoy/envoy.go b/command/connect/envoy/envoy.go index a917856f7f..cdceda2970 100644 --- a/command/connect/envoy/envoy.go +++ b/command/connect/envoy/envoy.go @@ -343,21 +343,6 @@ func (c *cmd) Run(args []string) int { return 1 } - // See if we need to lookup grpcAddr - if c.grpcAddr == "" { - port, err := c.lookupGRPCPort() - if err != nil { - c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) - } - if port <= 0 { - // This is the dev mode default and recommended production setting if - // enabled. - port = 8502 - c.UI.Info(fmt.Sprintf("Defaulting to grpc port = %d", port)) - } - c.grpcAddr = fmt.Sprintf("localhost:%v", port) - } - // Generate config bootstrapJson, err := c.generateConfig() if err != nil { @@ -411,6 +396,21 @@ func (c *cmd) templateArgs() (*BootstrapTplArgs, error) { return nil, err } + // See if we need to lookup grpcAddr + if c.grpcAddr == "" { + port, err := c.lookupGRPCPort() + if err != nil { + c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) + } + if port <= 0 { + // This is the dev mode default and recommended production setting if + // enabled. + port = 8502 + c.UI.Info(fmt.Sprintf("Defaulting to grpc port = %d", port)) + } + c.grpcAddr = fmt.Sprintf("localhost:%v", port) + } + // Decide on TLS if the scheme is provided and indicates it, if the HTTP env // suggests TLS is supported explicitly (CONSUL_HTTP_SSL) or implicitly // (CONSUL_HTTP_ADDR) is https://