Hey all, A few quick questions around Stacks and S...
# general
Hey all, A few quick questions around Stacks and Stack Configuration in Go. I am trying to “Force” that a user sets the “gcp:project” provider value using I am trying to place it in the config of the Pulum.yaml file as such:
Copy code
name: pulumi-project
runtime: go
description: it builds some infra
      description: The Google Cloud project to deploy into
However I get the following error message when I do a Pulumi Up:
Copy code
Configuration key 'gcp:project' is namespaced and must provide an attribute 'value'
Additionally I would then try and retrieve the prodiders project ID by reading it into another variable as follows:
Copy code
gcpProjectId := cfg.Require("gcp:project")
Is this the correct approach to access the providers project value? High Level Objectives: • Force users to set the Google Cloud Project ID in the Provider; • Access the Project ID programatically in the Pulumi Function.
Forcing it to be required isn't something we'd considered, but I guess that looks reasonable, if you want to raise an issue to track that we could probably get the config system fixed up pretty easy to enable it. Getting the project should just be
config.Get(ctx, "gcp:project")
So config.Require() doesn’t exist in the same way as for environment other config then? Ultimately I can programmatically catch it and handle it for now.
The top level functions take namespaces keys, e.g. "namespace:value"
I think once you have a Config type and call Get/Require on that it's limited to just one namespace (generally the project namespace)
Mmm okay; interesting thanks so much for the tips I’m gonna dive in and have a look see where I land. I might also raise and issue if I see it still of value.
I have a working Go project that uses multiple config namespaces:
Copy code
awsRegion := config.Require("aws:region")
keyPair := config.Require("keypairname")
Granted, I wrote this a while ago, but I just ran
pulumi up
with no issues (Go 1.19, Pulumi 3.76.1).