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

Handle errors properly in Logpush resource #564

Merged

Conversation

pawelkowalak
Copy link
Contributor

I was unable to create a Logpush resource in Cloudflare and error is not printed out. Here is example apply:

Error: error creating logpush job

  on cloudflare-log-push.tf line 34, in resource "cloudflare_logpush_job" "cloudflare_logpush":
  34: resource "cloudflare_logpush_job" "cloudflare_logpush" {

This is resource I'm trying to create:

// To generate ownership_challenge see: https://developers.cloudflare.com/logs/logpush/logpush-configuration-api/understanding-logpush-api/#ownership
resource "cloudflare_logpush_job" "cloudflare_logpush" {
  count               = var.cloudflare_logpush_challenge == "" ? 0 : 1
  zone_id             = var.cloudflare_zone_id_map[var.environment]
  name                = "Logpush Job for ${var.environment}"
  destination_conf    = "s3://${module.cloudflare_logpush_bucket.name}/{DATE}?region=${var.region}&sse=AES256"
  logpull_options     = "fields=RayID,ClientIP,EdgeStartTimestamp&timestamps=rfc3339"
  ownership_challenge = var.cloudflare_logpush_challenge
}

I've noticed that error creating logpush job log line is swallowing original error, probably from Cloudflare API, so I've created this PR to fill the gaps. Also fixed some other error messages.

@ghost ghost added the size/S label Dec 20, 2019
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.

Can you explain what your error ended up being and how this change fixed it? Right now I’m not sure how this has fixed any issues.

Using TF_LOG=DEBUG is also useful to track down where terraform is falling over.

cloudflare/resource_cloudflare_logpush_job.go Outdated Show resolved Hide resolved
@LeMyst
Copy link

LeMyst commented Feb 18, 2020

Hello,
I come here because I've issue with Logpush Job and terraform.
I don't know if @pawelkowalak have managed to create a logpush ressource, but I don't think the cloudflare_logpush_job can work in state.

There is a missing part in the cloudflare_logpush_job resource: you can't validate the challenge.

I think the easiest way to do that, is to call "GetLogpushOwnershipChallenge" when there is no challenge provided (and so, make the challenge non required), and when you update the ressource with the challenge, call the "ValidateLogpushOwnershipChallenge".

@pawelkowalak
Copy link
Contributor Author

Hi @Mystou, I didn't have time to debug it more or even check what error is hidden. We've created Logpush manually for now. We'll get back to this at some point probably. I'll update this PR according to @jacobbednarz comments.

@pawelkowalak pawelkowalak force-pushed the pk/logpush-handle-errors branch from 323ae6c to e401454 Compare February 18, 2020 16:38
@ghost ghost added size/XS and removed size/S labels Feb 18, 2020
@jacobbednarz jacobbednarz merged commit bdfc8e8 into cloudflare:master Mar 2, 2020
@jacobbednarz
Copy link
Member

Thanks for this @pawelkowalak 🎉 !

boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this pull request Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants