diff --git a/changelog/18315.txt b/changelog/18315.txt new file mode 100644 index 000000000..dc6984749 --- /dev/null +++ b/changelog/18315.txt @@ -0,0 +1,3 @@ +```release-note:improvement +hcp/connectivity: Include HCP organization, project, and resource ID in server startup logs +``` diff --git a/command/server.go b/command/server.go index 15c379364..df63cd1d6 100644 --- a/command/server.go +++ b/command/server.go @@ -1377,6 +1377,17 @@ func (c *ServerCommand) Run(args []string) int { info["fips"] = fipsStatus } + if config.HCPLinkConf != nil { + infoKeys = append(infoKeys, "HCP organization") + info["HCP organization"] = config.HCPLinkConf.Resource.Organization + + infoKeys = append(infoKeys, "HCP project") + info["HCP project"] = config.HCPLinkConf.Resource.Project + + infoKeys = append(infoKeys, "HCP resource ID") + info["HCP resource ID"] = config.HCPLinkConf.Resource.ID + } + sort.Strings(infoKeys) c.UI.Output("==> Vault server configuration:\n") @@ -1446,12 +1457,12 @@ func (c *ServerCommand) Run(args []string) int { return 1 } - hcpLogger := c.logger.Named("hcpLink") + hcpLogger := c.logger.Named("hcp-connectivity") hcpLink, err := hcp_link.NewHCPLink(config.HCPLinkConf, core, hcpLogger) if err != nil { - c.logger.Error("failed to start HCP Link", "error", err) + c.logger.Error("failed to establish HCP connection", "error", err) } else if hcpLink != nil { - c.logger.Trace("started HCP link") + c.logger.Trace("established HCP connection") } if c.flagTestServerConfig { diff --git a/command/server_test.go b/command/server_test.go index 18add1d23..4ffdd17a6 100644 --- a/command/server_test.go +++ b/command/server_test.go @@ -76,6 +76,13 @@ listener "tcp" { tls_cert_file = "TMPDIR/reload_cert.pem" tls_key_file = "TMPDIR/reload_key.pem" } +` + cloudHCL = ` +cloud { + resource_id = "organization/bc58b3d0-2eab-4ab8-abf4-f61d3c9975ff/project/1c78e888-2142-4000-8918-f933bbbc7690/hashicorp.example.resource/example" + client_id = "J2TtcSYOyPUkPV2z0mSyDtvitxLVjJmu" + client_secret = "N9JtHZyOnHrIvJZs82pqa54vd4jnkyU3xCcqhFXuQKJZZuxqxxbP1xCfBZVB82vY" +} ` ) @@ -268,6 +275,13 @@ func TestServer(t *testing.T) { 0, []string{"-test-verify-only"}, }, + { + "cloud_config", + testBaseHCL(t, "") + inmemHCL + cloudHCL, + "HCP Organization: bc58b3d0-2eab-4ab8-abf4-f61d3c9975ff", + 0, + []string{"-test-verify-only"}, + }, } for _, tc := range cases {