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

provider: update internal logging sink to use cloudflare-go logger #2123

Merged
merged 1 commit into from
Jan 4, 2023

Conversation

jacobbednarz
Copy link
Member

As of cloudflare/cloudflare-go#1164 we have the ability to use the inbuilt logger for redacting sensitive HTTP headers.

Previously, we were discarding the provided logger due to instantiating a new cleanhttp client to use however, with this change we are now using the cloudflare-go logger for HTTP interactions inside the Terraform Core sink.

By default we redact the values found in the following HTTP headers (not the headers themselves) in the entire HTTP interaction:

  • X-Auth-Email
  • X-Auth-Key
  • X-Auth-User-Service-Key
  • Authorization

And here is an example of the logger in action for TF_LOG=DEBUG.

2023-01-05T06:49:41.208221+11:00 [DEBUG] cloudflare
GET /client/v4/zones/0da42c8d2132a9ddaf714f9e7c920711/access/apps/dec500cc-4eb3-4c64-b10d-1fce8f686339 HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.3.6 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev
Content-Type: application/json
X-Auth-Email: [redacted]
X-Auth-Key: [redacted]
Accept-Encoding: gzip

2023-01-05T06:49:41.208221+11:00 [DEBUG] cloudflare
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cf-Cache-Status: DYNAMIC
Cf-Ray: 78467fb52e4baaf9-SYD
Connection: keep-alive

...

{
  "result": {
    "id": "dec500cc-4eb3-4c64-b10d-1fce8f686339",
    "uid": "dec500cc-4eb3-4c64-b10d-1fce8f686339",
    // ..
    "http_only_cookie_attribute": false
  },
  "success": true,
  "errors": [],
  "messages": []
}

As of cloudflare/cloudflare-go#1164 we have the ability to use the
inbuilt logger for redacting sensitive HTTP headers.

Previously, we were discarding the provided logger due to instantiating
a new `cleanhttp` client to use however, with this change we are now
using the cloudflare-go logger for HTTP interactions inside the
Terraform Core sink.

By default we redact the values found in the following HTTP headers (not
the headers themselves) in the entire HTTP interaction:

- `X-Auth-Email`
- `X-Auth-Key`
- `X-Auth-User-Service-Key`
- `Authorization`

And here is an example of the logger in action for `TF_LOG=DEBUG`.

```
2023-01-05T06:49:41.208221+11:00 [DEBUG] cloudflare
GET /client/v4/zones/0da42c8d2132a9ddaf714f9e7c920711/access/apps/dec500cc-4eb3-4c64-b10d-1fce8f686339 HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.3.6 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev
Content-Type: application/json
X-Auth-Email: [redacted]
X-Auth-Key: [redacted]
Accept-Encoding: gzip

2023-01-05T06:49:41.208221+11:00 [DEBUG] cloudflare
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cf-Cache-Status: DYNAMIC
Cf-Ray: 78467fb52e4baaf9-SYD
Connection: keep-alive

...

{
  "result": {
    "id": "dec500cc-4eb3-4c64-b10d-1fce8f686339",
    "uid": "dec500cc-4eb3-4c64-b10d-1fce8f686339",
    // ..
    "http_only_cookie_attribute": false
  },
  "success": true,
  "errors": [],
  "messages": []
}
```
@github-actions
Copy link

github-actions bot commented Jan 4, 2023

changelog detected ✅

@jacobbednarz jacobbednarz merged commit 1fd2f69 into master Jan 4, 2023
@jacobbednarz jacobbednarz deleted the update-tf-debug-logger branch January 4, 2023 23:26
@github-actions github-actions bot added this to the v3.32.0 milestone Jan 4, 2023
github-actions bot pushed a commit that referenced this pull request Jan 4, 2023
@github-actions
Copy link

This functionality has been released in v3.32.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

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

Successfully merging this pull request may close these issues.

1 participant