title: Deploying Google Cloud Function by Terraform got "Error 400: The request has errors, badRequest"
body: <p>I want to deploy Cloud Function by Terraform but it fails.</p>
  
  <p><code>export TF_LOG=DEBUG</code><br>
  <code>terraform init</code><br>
  <code>terraform plan # it does not fail</code><br>
  <code>terraform apply # this fail</code>  </p>
  
  <pre><code>{
    "error": {
      "code": 400,
      "message": "The request has errors",
      "errors": [
        {
          "message": "The request has errors",
          "domain": "global",
          "reason": "badRequest"
        }
      ],
      "status": "INVALID_ARGUMENT"
    }
  }
  </code></pre>
  
  <h1>What I tired</h1>
  
  <ul>
  <li>I tried to change the trigger to HTTP but the deployment also failed.</li>
  <li>enable TF_LOG</li>
  <li>do <code>terraform plan</code> but it succeeded</li>
  </ul>
  
  <h1>terraform template</h1>
  
  <p>below is my main.tf file</p>
  
  <pre><code>resource "google_pubsub_topic" "topic" {
    name    = "rss-webhook-topic"
    project = "${var.project_id}"
  }
  
  
  resource "google_cloudfunctions_function" "function" {
    name                = "rss-webhook-function"
    entry_point         = "helloGET"
    available_memory_mb = 256
    project             = "${var.project_id}"
  
    event_trigger {
      event_type = "google.pubsub.topic.publish"
      resource   = "${google_pubsub_topic.topic.name}"
    }
  
    source_archive_bucket = "${var.bucket_name}"
    source_archive_object = "${google_storage_bucket_object.archive.name}"
  }
  
  data "archive_file" "function_src" {
    type        = "zip"
    output_path = "function_src.zip"
  
    source {
      content  = "${file("src/index.js")}"
      filename = "index.js"
    }
  }
  
  resource "google_storage_bucket_object" "archive" {
    name       = "function_src.zip"
    bucket     = "${var.bucket_name}"
    source     = "function_src.zip"
    depends_on = ["data.archive_file.function_src"]
  }
  
  </code></pre>
  
  <h1>environment</h1>
  
  <p>Terraform version: 0.11.13<br>
  Go runtime version: go1.12
  + provider.archive v1.2.2
  + provider.google v2.5.1</p>