docs icon indicating copy to clipboard operation
docs copied to clipboard

Errant vars in code samples

Open joeduffy opened this issue 5 years ago • 1 comments

Many of our code samples include things like

  • JS/TS: var_s3_bucket_name
  • Python: var['s3_bucket_name']
  • C#: @var.s3_bucket_name

For example, see many of the examples here.

Is this because the source program uses config? If so, should we be emitting examples that use the Pulumi configuration system to read those variables?

As it stands, it leads to code that won't compile and can be confusing to users.

joeduffy avatar Jun 01 '20 23:06 joeduffy

This is more or less the same issue tracked in https://github.com/pulumi/pulumi/issues/14463.

There are two parts to this:

  1. The examples are "incomplete" in that they reference variables that aren't defined in the example
  2. The names that are generated are "weird" and look unnatural.

Part (1) is inherited from the upstream examples. They are very frequently not complete and standalone pieces of code, and assume that some number of variables or other resources were defined outside of the example. We could try to fix some or all of these, but for the same reason that the upstream examples chose to go the route of not being 100% complete code, it's likely that practically we will want to have some/many examples that do refer to things not explicitly present in the code example. We could choose to emit const s3_bucket_name = ... or something similar to more explicitly indicate this piece is being left out.

Part (2) we should fix to have the code example read more "naturally" for users of each Pulumi language.

lukehoban avatar Jun 01 '20 23:06 lukehoban

Closing this out as a dupe of https://github.com/pulumi/pulumi/issues/14463 which covers the same thing (though the exact way it shows up has changed since this issue was opened).

lukehoban avatar Oct 31 '23 17:10 lukehoban