Add logging during awskms auto-unseal#9794
Conversation
Adds debug and warn logging around AWS credential chain generation, specifically to help users debugging auto-unseal problems on AWS, by logging which role is being used in the case of a webidentity token. Adds a deferred call to flush the log output as well, to ensure logs are output in the event of an initialization failure.
| SecretAccessKey: c.SecretKey, | ||
| SessionToken: c.SessionToken, | ||
| }}) | ||
| c.Logger.Debug("added static credential provider", "AccessKey", c.AccessKey) |
There was a problem hiding this comment.
c.Logger could potentially be nil if none is passed into CredentialsConfig so these calls would panic. Let's wrap logger calls with a nil check.
| } | ||
|
|
||
| creds, err := RetrieveCreds(m["aws_access_key_id"], m["aws_secret_access_key"], m["aws_security_token"]) | ||
| creds, err := RetrieveCreds(m["aws_access_key_id"], m["aws_secret_access_key"], m["aws_security_token"], hclog.Default()) |
There was a problem hiding this comment.
This does not derive any of the logging properties from the main command, so it might result in different format, log level, etc.
There was a problem hiding this comment.
How would we get the logging properties from the main command here? I haven't found a way to do that.
There was a problem hiding this comment.
The log would be from the client (result from a vault login command) for this particular case so it might be fine, though hclog.Default() logs up to Info only, so it would skip any Debug output.
There was a problem hiding this comment.
I'm not seeing anywhere else in the vault login command that verbosity levels are set, so in 2271d6c I added a log_level option to the aws cli login command, and used that to configure the logger passed to RetrieveCreds(). Or maybe it's preferable to just pass a null logger here?
Used to setup the logger for use in GenerateCredentialChain()
| github.com/hashicorp/go-gcp-common v0.6.0 | ||
| github.com/hashicorp/go-hclog v0.14.1 | ||
| github.com/hashicorp/go-kms-wrapping v0.5.12 | ||
| github.com/hashicorp/go-kms-wrapping v0.5.15 |
There was a problem hiding this comment.
We should be using v0.5.16 right?
* adds error handling for control groups to api service as post request middleware * updates kv list route to use api service * updates kv config route to use api service * updates kv secrets overview route to use api service * updates kv secret details route to use api service * adds kv form * updates kv metadata details route to use api service * updates kv paths and version history routes to use api service * refactors kv-data-fields component to form component * updates kv secret create route to use api service * updates kv secret edit route to use api service * updates kv metadata edit route to use api service * adds waitFor to async middleware in api service to attempt to fix race conditions in tests * adds kvMetadata path to capabilities path map * fixes kv list item delete test selector * removes kv models, adapters and serializers * removes store from kv addon * removes ember data related test helpers from kv-run-commands * updates comments that referred to kv ember data models * updates kv-page-header tests * updates model-form-fields test to use totp-key model rather than kv/data * removes another reference to kv/data model from path-help test * fixes kv v2 workflow create tests * fixes issue returning metadata for secret when latest version is deleted * decodes uri in path returned by api service parseError method * fixes kv v2 edge cases tests * fixes issue deleteing control group token in api service * decodes url for control group token lookup in api service * fixes version history linked block link * defaults cas to 0 when creating new secret * removes log * adds ember-template-lint to kv engine * more test fixes * updates kv-suggestion-input component to use api service * removes kv metadata model reference from quick actions card * fixes sync destination sync secrets tests * updates kv helpers from classic format * updates kv helpers imports * reverts to use secret.version in details edit route * fixes isDeleted import in kv version history test * adds waitFor to api service parseError method * reverts removing async from addQueryParams api method * attempts to fix test flakiness requesting custom metadata from data endpoint * more tweaks to requesting metadata from data * adds waitFor to requestData method Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
Adds debug and warn logging around AWS credential chain generation, specifically to help users understand why auto-unseal isn't working on AWS, by logging which role is being used in the case of a webidentity token.
Also in the case of webidentity, this tests retrieving credentials, and logs a warning if it has trouble, in which case it falls through to using creds from the instance metadata, which may still fail, but with a warning logged at least users can tell why the webidentity auth failed.
Depends on hashicorp/go-kms-wrapping#22
Example logging with level=trace when auto-unseal fails:
before:
after: