pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
183 stars 53 forks source link

No error details when trying to deploy a google cloud function #150

Open arsanjea opened 5 years ago

arsanjea commented 5 years ago

While trying to deploy a google cloud function with pulumi, I get very little information as to what went wrong which leads to hours of troubleshooting efforts. Example: It took me a lot of troubleshooting to figure out why pulumi wasn't able to deploy the following piece of code:

const functionNodejs = new gcp.cloudfunctions.Function("hello", {
  environmentVariables: {
    NODE_ENV: 'production',
  },
  sourceArchiveBucket: bucket.name,
  runtime: "nodejs8",
  sourceArchiveObject: bucketObjectNodejs.name,
  entryPoint: "hello",
  triggerHttp: true,
  availableMemoryMb: 512,
  timeout: 540,
});

Pulumi's output was:

Diagnostics:
  pulumi:pulumi:Stack (test):
    error: update failed

  gcp:cloudfunctions:Function (hello):
    error: Plan apply failed: 1 error occurred:
        * updating urn:pulumi:test/function:Function::hello: Error while updating cloudfunction configuration: googleapi: Error 400: The request has errors, badRequest

After hours of troubleshooting I figured out that NODE_ENV was not environment variable a user is allowed to set.

I was able to identify this issue by running: gcloud functions deploy hello --update-env-vars NODE_ENV=production --trigger-http

Which gives the - much more helpful - following output:

dist zeus$ gcloud functions deploy hello --update-env-vars NODE_ENV=production --trigger-http --runtime nodejs8
ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Bad Request], message=[The request has errors
Problems:
environment variable name NODE_ENV is reserved by the system: it cannot be set by users
]

Would it possible for pulumi to capture this output?

CyrusNajmabadi commented 5 years ago

That's very unfortunate. We can see what is possible, but we may be very limited ultimately by what the underlying terraform provider does. In order to improve this, it might necessitate a change at their layer to some collect and pass along more information when their call into the googleapi fails.