Add HCP connectivity info to `vault server` startup logs (#18315)
* add HCP org, proj, and resource ID to server startup logs * add server config test for cloud stanza * add changelog entry
This commit is contained in:
parent
0c181f8f25
commit
a545b1f22d
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
hcp/connectivity: Include HCP organization, project, and resource ID in server startup logs
|
||||
```
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue