Terraform-provider-google: Deploying Google Cloud Function by Terraform got "Error 400: The request has errors, badRequest"

Created on 17 Apr 2020  ·  4Comments  ·  Source: hashicorp/terraform-provider-google


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave _+1_ or _me too_ comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.12.24

  • provider.archive v1.3.0
  • provider.google v3.17.0
  • provider.google-beta v3.17.0

Affected Resource(s)

  • google_cloudfunctions_function

Terraform Configuration Files

resource "google_pubsub_topic" "start_instance_event" {
  project = var.project
  name    = "start-instance-event"

  labels = {
    service = "pubsub"
    topic   = "start-instance-event"
  }
}

resource "google_storage_bucket" "cloudfunctions_fetcher_env" {
  name          = "cloudfunction-${var.project}"
  location      = var.region
  project       = var.project
  storage_class = "REGIONAL"
}

data "archive_file" "startInstancePubSub" {
  type        = "zip"
  output_path = "${path.module}/files/startInstancePubSub.zip"

  source {
    content  = "${file("${path.module}/files/startInstancePubSub/index.js")}"
    filename = "index.js"
  }

  source {
    content  = "${file("${path.module}/files/startInstancePubSub/package.json")}"
    filename = "package.json"
  }
}

resource "google_cloudfunctions_function" "startInstancePubSub" {
  name                  = "startInstancePubSub"
  runtime               = "nodejs8"
  entry_point           = "startInstancePubSub"
  available_memory_mb   = 256
  timeout               = 60
  project               = var.project
  region                = var.region
  ingress_settings      = "ALLOW_INTERNAL_ONLY"
  source_archive_bucket = google_storage_bucket.cloudfunctions_fetcher_env.name
  source_archive_object = google_storage_bucket_object.startInstancePubSub.name

  event_trigger {
    event_type = "google.pubsub.topic.publish"
    resource   = google_pubsub_topic.start_instance_event.name
  }

  labels = {
    deployment_name = "startInstancePubSub"
  }
}

Debug Output

{
  "error": {
      "code": 400,
      "message": "The request has errors",
      "errors": [
        G] plugin.terraform-provider-google_v3.17.0_x5:       {
        "message": "The request has errors",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Panic Output

Expected Behavior

Actual Behavior

I try to deploy cloud function by terraform with use trigger PubSub, but it fails.

Steps to Reproduce

  1. export TF_LOG=DEBUG
  2. terraform init
  3. terraform plan - this OK
  4. terraform apply - this fail

Important Factoids

References

  • #0000
bug

Most helpful comment

@SergeSpinoza our internal log shows format errors for labels block, API accepts only lower case values for labels { key : value}. I will create an issue for our doc update.

changing your labels to lower case should fix the issue.

All 4 comments

@SergeSpinoza i don't see which resource was failing from your debug log. Can you provide the full debug log to get a better idea?

@SergeSpinoza our internal log shows format errors for labels block, API accepts only lower case values for labels { key : value}. I will create an issue for our doc update.

changing your labels to lower case should fix the issue.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings