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

Add support logpush filters #1660

Merged

Conversation

yknx4
Copy link
Contributor

@yknx4 yknx4 commented May 31, 2022

closes #1632

Hello ~
Our team at Shopify worked on added support for LogpushJob filter in cloudflare/cloudflare-go#915 and now we are looking to updating the terraform-provider

Right now this depends on the master build of cloudflare-go so it probably requires a release on your side. But it would help to have some eyes on it.

schema/logpush_job: Add `filter` attribute
resource/logpush_job: Add `filter` field support

Pending

  • Use next release of cloudflare-go instead of master branch

Examples

This has some redacted fields

Config

resource "cloudflare_logpush_job" "lowvolume" {
  name                = "${local.domain}-HTTP-lowvolume-request-logs"
  zone_id             = cloudflare_zone.zone.id
  destination_conf    = "gs://${local.log_bucket}/cloudflare/http/${local.domain}/{DATE}"
  ownership_challenge = local.cloudflare_logpush_ownership_challenge_response
  dataset             = "http_requests"
  logpull_options     = "timestamps=unixnano&....."
  filter = jsonencode({
    "where" : {
      "and" : [
        {
          "key" : "ClientRequestHost",
          "operator" : "in",
          "value" : [
            "foo.mydomain2.com",
            "cdn.myapp.com",
            "cdn.mydomain2.net",
            "bar.mydomain2.com",
            "myapp-assets.mydomain2.com",
            "myapp-assets.mydomain2.net"
          ]
        },
        {
          "key" : "ClientRequestPath",
          "operator" : "!startsWith",
          "value" : "/asset/"
        },
        {
          "key" : "ClientRequestPath",
          "operator" : "!startsWith",
          "value" : "/admin/"
        }
    ] }
  })

  enabled = true
}

Output

Terraform will perform the following actions:

  # cloudflare_logpush_job.highvolume will be updated in-place
  ~ resource "cloudflare_logpush_job" "highvolume" {
      ~ enabled             = true -> false
        id                  = "77975"
        name                = "apps.myapp.com-HTTP-highvolume-request-logs"
        # (7 unchanged attributes hidden)
    }

  # cloudflare_logpush_job.lowvolume will be updated in-place
  ~ resource "cloudflare_logpush_job" "lowvolume" {
      ~ enabled             = true -> false
      ~ filter              = jsonencode(
          ~ {
              ~ where = {
                  ~ and = [
                        {
                            key      = "ClientRequestHost"
                            operator = "in"
                            value    = [
                                "foo.mydomain2.com",
                                "cdn.myapp.com",
                                "cdn.mydomain2.net",
                                "bar.mydomain2.com",
                                "myapp-assets.mydomain2.com",
                                "myapp-assets.mydomain2.net",
                            ]
                        },
                      ~ {
                          - and      = [
                              - {
                                  - key      = "ClientRequestPath"
                                  - operator = "!startsWith"
                                  - value    = "/assets/"
                                },
                              - {
                                  - key      = "ClientRequestPath"
                                  - operator = "!startsWith"
                                  - value    = "/admin/"
                                },
                            ] -> null
                          + key      = "ClientRequestPath"
                          + operator = "!startsWith"
                          + value    = "/assets/"
                        },
                      + {
                          + key      = "ClientRequestPath"
                          + operator = "!startsWith"
                          + value    = "/admin/"
                        },
                    ]
                }
            }
        )
        id                  = "99999"
        name                = "apps.myapp.com-HTTP-lowvolume-request-logs"
        # (6 unchanged attributes hidden)
    }

Plan: 0 to add, 2 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

cloudflare_logpush_job.highvolume: Modifying... [id=77975]
cloudflare_logpush_job.lowvolume: Modifying... [id=77979]
cloudflare_logpush_job.lowvolume: Modifications complete after 2s [id=77979]
cloudflare_logpush_job.highvolume: Modifications complete after 2s [id=77975]

@yknx4 yknx4 requested a review from jacobbednarz as a code owner May 31, 2022 21:46
@github-actions
Copy link
Contributor

Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/docs/changelog-process.md.

Example:

```release-note:TYPE
Release note
```

If you do not require a release note to be included, please add the workflow/skip-changelog-entry label.

@github-actions
Copy link
Contributor

This project handles dependency version bumps (including upstream changes from cloudflare-go) independently of the standard PR process using automation. This allows the dependency upgrades to land without causing merge conflicts in multiple branches and handled in a consistent way. The exception to this is security related dependency upgrades but they should be co-ordinated with the maintainer team privately.

Please remove the changes to the go.mod or go.sum files from this PR in order to proceed with review and merging.

Copy link
Member

@jacobbednarz jacobbednarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good! we'll need to:

once those are in, i'll run some acceptance tests and get this marked as ready for merge.

@yknx4 yknx4 requested a review from jacobbednarz June 1, 2022 16:17
Copy link
Member

@jacobbednarz jacobbednarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! just waiting on the next cloudflare-go release to land. locally this looks good.

yknx4 added a commit to Shopify/terraform-provider-cloudflare that referenced this pull request Jun 2, 2022
yknx4 added a commit to Shopify/terraform-provider-cloudflare that referenced this pull request Jun 2, 2022
@jacobbednarz
Copy link
Member

i attempted to automatically update this branch for you now that cloudflare-go@v0.41.0 has landed but it looks to be blocked in your fork. feel free to bump it and we can kick off the acceptance test suite for you.

@yknx4 yknx4 force-pushed the jade/support-logpush-filters branch from 771a937 to b7b13e6 Compare June 8, 2022 15:26
.changelog/1664.txt Outdated Show resolved Hide resolved
@jacobbednarz
Copy link
Member

this looks good! thanks 👏 i'll update the documentation in another PR to get it automatically generated.

Co-authored-by: Jacob Bednarz <jacob.bednarz@hey.com>
@yknx4
Copy link
Contributor Author

yknx4 commented Jun 8, 2022

@jacobbednarz ok. Thank you very much for your support

@jacobbednarz
Copy link
Member

jacobbednarz commented Jun 8, 2022

@jacobbednarz jacobbednarz merged commit 6809315 into cloudflare:master Jun 8, 2022
@github-actions github-actions bot added this to the v3.17.0 milestone Jun 8, 2022
@yknx4 yknx4 deleted the jade/support-logpush-filters branch June 9, 2022 00:18
@jacobbednarz
Copy link
Member

migrated to autogen docs in #1686

@github-actions
Copy link
Contributor

This functionality has been released in v3.17.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!

yknx4 added a commit to Shopify/terraform-provider-cloudflare that referenced this pull request Jun 16, 2022
sbfaulkner pushed a commit to Shopify/terraform-provider-cloudflare that referenced this pull request Jun 20, 2022
sbfaulkner pushed a commit to Shopify/terraform-provider-cloudflare that referenced this pull request Jun 20, 2022
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.

cloudflare_logpush_job - Support filter
2 participants