docs
docs copied to clipboard
Update Pulumi configuration page to show simple but complete examples
Specifically referring to the "Accessing Configuration from Code" section, unless you are familiar with a specific programming language, it is not very clear how to actually do this in code. For example, the C# code example shows the following:
var config = new Pulumi.Config();
var name = config.Require("name");
var lucky = config.GetInt32("lucky") ?? 42;
var secret = config.RequireSecret("secret")
When what it should really show is something like this:
using Pulumi;
using System.Threading.Tasks;
using System.Collections.Generic;
class Program
{
static async Task<int> Main(string[] args)
{
return await Deployment.RunAsync(() =>
{
// Import the configuration values
var config = new Config();
// Retrieve the value of "myEnvironment"
var myValue = config.Get("myEnvironment") ?? "default-value";
// Return a dictionary of outputs
return new Dictionary<string, object?>
{
["Value"] = myValue
};
});
}
}