pulumi-gcp: Missing configuration leads to poor errors

If I neglect to set my project, region, or zone configuration, I get an unhelpful error message:

error: Plan apply failed: project: required field is not set

Given that this will happen almost guaranteed for every new user of Pulumi on GCP, we should try to make this experience better. IIRC, we have some trick that we already use in the AWS package to hook errors like this and prettify them before displaying to the end user.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 16 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I believe @ellismg and @jen20 looked into this and concluded it isn’t as easy as copying what we do in the AWS package, since you can set these on a per-resource basis.

This would be a very unfortunate conclusion. Here is a common experience with basic GCP programs, annotated with some of my own commentary/questions:

  • Initialize a GCP project/stack.
  • Run pulumi up:
    • Preview looks great! No errors. I hit “yes” to proceed.
    • The first GCP resource attempted to be created fails with an error, Plan apply failed: project: required field is not set
  • As a new user, I have no idea how to proceed. Hopefully my tutorial tells me what to do. Google actually lands me on a bug from nearly one year ago where users were confused by this very thing!
    • Question: Why doesn’t this use my default gcloud project? If I run gcloud info, it prints out the very project I want to use…
    • Eventually, I figure out to run pulumi config set gcp:project my-project
    • Question: Is there any way for the error message to tell me how to fix the problem?
  • I rerun pulumi up:
    • Again, the preview looks great. I hit “yes”.
    • Again a failure, and again minimal or obscure commentary on how to proceed: Plan apply failed: Cannot determine region: set in this resource, or set provider-level 'region' or 'zone'.
  • Again, as a new user, I’m probably stumped. Sadly, for this one Googling doesn’t help.
    • The solution is to set either the region or zone, using pulumi config set gcp:region us-east1.
    • Question: Is there any way for the error message to tell me how to fix the problem?

@ellismg I know you had feedback on the GCP getting started flow. I’m actually wondering whether this was a problem for others on the team, or whether our tutorials make it so you don’t stumble here. (I’m always stumbling, but maybe I’m not paying close enough attention.) Thoughts?

Also /cc @swgillespie as I know improving errors is/was a passion of his, and I’m curious if he’s ever looked into this sort of “error rewriting” we might need to do on the fly in order to improve these messages.

I really liked the suggestion by https://github.com/pulumi/pulumi-gcp/issues/1641: Keep the get region call as a happy path for error messages, but don’t let it introduce a failure.

Reopening this because we had to revert because of a regression introduced by region validation. https://github.com/pulumi/pulumi-gcp/issues/1641 - this needs a little bit of rework to carefully account for Workload Identity Federation / OIDC style of authentication, not failing region validation when get region permission is unset as the user mentions in 1641.

I think most of the originally reported problems are no longer true. GCP now reports missing config as in @t0yv0’s comment above.

https://github.com/pulumi/pulumi-gcp/pull/1552 should address the duplicate warning about the lack of global project.

I am also working on adding validation for the region config in https://github.com/pulumi/pulumi-gcp/pull/1554

I actually just ran into this, and until I found this issue it wasn’t at all clear what the issue way.

One thing that was very helpful with the AWS provider is that when a required field is missing, like the aws:region configuration option, you get a much more helpful error:

aws:s3:Bucket (bucket):
    error: 1 error occurred:
        * missing required configuration key "aws:region": The region where AWS operations will take place. Examples are us-east-1, us-west-2, etc.
    Set a value using the command `pulumi config set aws:region <value>`.

Can we at least make the error message clearer, or have the previous comments indicated why that isn’t possible?

we’ve been hit by it and it was confusing. I realise that upstream is not going to fix it,but it doesn’t mean Pulumi can’t do it’s part. One way would be to do merging with ambient defaults on Pulumi side and always pass project to TF explicitly or error before even calling TF is project is not set.