mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
plugins/rest/aws: debug log metadata error (#4061)
A user on Slack is getting 500 responses from the AWS metadata API
using a configuration like the below:
```yaml
services:
- name: svc-bundle
url: https://opa-policies-dev.s3.amazonaws.com
credentials:
s3_signing:
metadata_credentials:
aws_region: us-east-1
iam_role: arn:aws:iam::1234:role/opa-bundles
```
It's really hard to know why this might be given how we currently
only log the HTTP status code under this error condition.
This tries to print the response body on debug level (if set).
Signed-off-by: Anders Eknert <anders@eknert.com>
This commit is contained in:
@@ -378,6 +378,12 @@ func doMetaDataRequestWithClient(req *http.Request, client *http.Client, desc st
|
||||
}).Debug("Received response from " + desc + " service.")
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if logger.GetLevel() == logging.Debug {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
logger.Debug("Error response with response body: %v", body)
|
||||
}
|
||||
}
|
||||
// could be 404 for role that's not available, but cover all the bases
|
||||
return nil, errors.New(desc + " HTTP request returned unexpected status: " + resp.Status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user