This message was deleted.
# getting-started
s
This message was deleted.
r
You can make a config key required by calling it with
config.require()
in the code rather than by defining the schema for it in the pulumi.yaml: https://www.pulumi.com/docs/intro/concepts/config/#:~:text=let%20name%20%3D%20config.require(%22name%22)%3B
There is no way to define the expected schema of the config in the pulumi.yaml
s
Ah ok. Thanks! This was misleading to me, as the docs suggest the pattern you saw https://www.pulumi.com/docs/intro/concepts/config/#code with the example:
Copy code
configuration:
  name:
    type: String
  lucky:
    default: 42
outputs:
  stdout: Hello, ${name} -- I see your lucky number is ${lucky}!
Not big deal. 😄 Was just trying to establish best practices.
r
Ah! That is indeed the case if you are writing your pulumi program in YAML rather than any of the programming languages.
s
Ah okay, the string validation does seem to work for outputs. Just not within resources.
Might not be intended for resources though.
r
Ah okay, the string validation does seem to work for outputs. Just not within resources.
I'm not sure I understand - is this still in relation to configuration?
s
Yeah. Pulumi.yaml like this:
Copy code
name: kubernetes
runtime: yaml
description: A minimal Google Cloud Pulumi YAML program
variables:
    project: ${pulumi.project}
configuration:
  cluster_name:
    type: String
resources:
  gke-cluster:
    type: gcp:container:Cluster
    properties:
      location: europe-west2
      name: ${cluster_name}
Produces this preview:
Copy code
* #/config/cluster_name: oneOf failed
	* #/config/cluster_name: expected string, but got object
	* #/config/cluster_name: expected integer, but got object
	* #/config/cluster_name: expected boolean, but got object
	* #/config/cluster_name: expected array, but got object
	* #/config/cluster_name: doesn't validate with '/$defs/configTypeDeclaration'
	* #/config/cluster_name/type: doesn't validate with '/$defs/simpleConfigType'
	* #/config/cluster_name/type: value must be one of "string", "integer", "boolean", "array"
with this config
Copy code
config:
  gcp:project: "new"
  kubernetes:cluster_name: "test"
But this might go back to your answer that YAML won't support this.
The error catching does work better in Yaml with config variable referenced against outputs
Copy code
error: missing required configuration variable 'cluster_name'; run `pulumi config` to set
r
* #/config/cluster_name/type: value must be one of "string", "integer", "boolean", "array"
This last line implies that the type declaration in your pulumi.yaml should be lower-case:
Copy code
configuration:
  cluster_name:
    type: string
But yeah, the docs have it as capitalized. Indeed confusing.
What you're doing should work, config is made to be passed into resources. There is something odd going on here.