SumoLogic / terraform-provider-sumologic

Terraform provider for Sumo Logic
https://www.terraform.io/docs/providers/sumologic/
Mozilla Public License 2.0
40 stars 57 forks source link

Unable to create gcp_source resource #179

Open brionmoss opened 3 years ago

brionmoss commented 3 years ago

For a while early this year, I was able to set up and manage Sumo Logic collectors for our GCP resources using the terraform module. This week, it's no longer working. I get this error:

Error: {
  "status" : 400,
  "id" : "CLT9V-1KCON-ZTJ7B",
  "code" : "collectors.validation.fields.missing",
  "message" : "Missing required field: 'resources'"
}

  on ../../../../../ops-terraform-modules-services/sumologic/main.tf line 3, in resource "sumologic_gcp_source" "gcp_source":
   3: resource "sumologic_gcp_source" "gcp_source" {

The referenced terraform code looks like this:

# Create a HTTP source
resource "sumologic_gcp_source" "gcp_source" {
    name         = var.name
    category     = format("%s/%s", var.project_id, var.name)
    collector_id = var.collector
    filters {
      name        = "Exclude users-backend noise"
      filter_type = "Exclude"
      regexp      = ".*twitter: nibbler-raw-http-client: name resolution is negative.*"
    }
}

This is the plan terraform generates:

  # module.architecture.module.sumologic["healthcheck"].sumologic_gcp_source.gcp_source will be created
  + resource "sumologic_gcp_source" "gcp_source" {
      + automatic_date_parsing       = true
      + category                     = "rl-us-stage02/healthchecks"
      + collector_id                 = 224120103
      + content_type                 = "GoogleCloudLogs"
      + cutoff_timestamp             = 0
      + force_timezone               = false
      + id                           = (known after apply)
      + message_per_request          = false
      + multiline_processing_enabled = true
      + name                         = "healthchecks"
      + timezone                     = "Etc/UTC"
      + url                          = (known after apply)
      + use_autoline_matching        = true

      + filters {
          + filter_type = "Exclude"
          + name        = "Exclude users-backend noise"
          + regexp      = ".*twitter: nibbler-raw-http-client: name resolution is negative.*"
        }
    }

I started with provider version 2.6.3, but updated to 2.9.1 when I hit this bug; the behavior is the same with either version.

yonghaoy commented 3 years ago

+1 same error here

fallard84 commented 3 years ago

Adding the following, as per the example, fixes the issue for me:

authentication {
  type = "NoAuthentication"
}

path {
  type = "NoPathExpression"
}

I just wished the doc would explain what those are 🤷

yonghaoy commented 3 years ago

Also, where can I find example on how to use authentication field? I think we need that to enable pubsub push authentication? I recalled there used to be some instruction here: https://help.sumologic.com/03Send-Data/Sources/02Sources-for-Hosted-Collectors/Google-Cloud-Platform-Source that tells me how to setup domain verification in GCP but now it is removed. Is that because no longer needed or that part is moved to somewhere else?

vsinghal13 commented 3 years ago

@fallard84 thanks for sharing the example. Since domain verification is no longer required, those fields are just placeholders and do not need to be modified. We can definitely add some documentation to clarify the same.

fallard84 commented 3 years ago

This is also required to prevent Terraform from always trying to reapply the path block:

lifecycle {
    ignore_changes = [
      path
    ]
  }
antonmos commented 1 year ago

Adding the following, as per the example, fixes the issue for me:

authentication {
  type = "NoAuthentication"
}

path {
  type = "NoPathExpression"
}

I just wished the doc would explain what those are 🤷

even though the docs PR was merged, the example is still not updated at https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/gcp_source

fwiw, you can see docs at https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/s3_source#authentication

antonmos commented 1 year ago

this is still happening with sumologic provider v2.41 Could a more informative error be thrown please? it was really hard to find this github issue

vsinghal13 commented 1 year ago

@samjsong can you take a look at this?