Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output HTTP Response Logs as Debug Logs #133

Open
tanopanta opened this issue Jun 19, 2024 · 0 comments
Open

Output HTTP Response Logs as Debug Logs #133

tanopanta opened this issue Jun 19, 2024 · 0 comments

Comments

@tanopanta
Copy link
Contributor

Summary

When TF_LOG=DEBUG is set, request logs are output in [INFO] logs, but response logs are not.
If response logs were also output, it would be convenient to obtain information about the created resource details and RequestId.

Environment

  • terraform v1.5.7
  • terraform provider v1.14.0
  • export TF_LOG=DEBUG

NOTE

However, in the case of an error, the error response is formatted and output as [ERROR].
But the response information, including headers that were obtained with [INFO] in #90, is not obtained.

> 2024-06-18T13:50:06.883Z [INFO]  provider.terraform-provider-nifcloud_v1.14.0: 2024/06/18 13:50:06 DEBUG Request
> POST /api/ HTTP/1.1
> Host: jp-east-1.computing.api.nifcloud.com
> User-Agent: aws-sdk-go-v2/1.17.4 os/linux lang/go/1.20.3 md/GOOS/linux md/GOARCH/amd64 api/computing/1.22.1
> Content-Length: 256
> Amz-Sdk-Invocation-Id: 2818f70e-ba4e-47ad-b684-de0160fd45ce
> Amz-Sdk-Request: attempt=1; max=1
> Content-Type: application/x-www-form-urlencoded
> Accept-Encoding: gzip
> 
> AccessKeyId={masked}&Action=ImportKeyPair&Description=&KeyName=deployerkey&PublicKeyMaterial=YQo%3D&Signature={masked}&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2024-06-18T13%3A50%3A06Z&Version=3.0: timestamp=2024-06-18T13:50:06.883Z
> 2024-06-18T13:50:07.354Z [ERROR] provider.terraform-provider-nifcloud_v1.14.0: Response contains error diagnostic: tf_proto_version=5.3 tf_resource_type=nifcloud_key_pair tf_rpc=ApplyResourceChange tf_provider_addr=provider tf_req_id=165ffd33-fbad-caa1-ae62-2475a98ee15e @caller=/home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.16.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="failed creating KeyPair: operation error computing: ImportKeyPair, https response error StatusCode: 500, RequestID: 704f1dd9-12d8-41a8-9d71-fa2c62234b93, api error Client.AuthFailurePermission.AccessKey: This system was not able to validate the provided access key." timestamp=2024-06-18T13:50:07.354Z

Reference Information

It seems possible to output them by changing cfg.ClientLogMode = aws.LogRequestWithBody to cfg.ClientLogMode = aws.LogRequestWithBody | aws.LogResponseWithBody.

https://github.com/nifcloud/terraform-provider-nifcloud/blob/main/nifcloud/provider_config.go#L35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant