Skip to content

Update Pulumi configuration page to show simple but complete examples #10723

@toriancrane

Description

@toriancrane

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
            };
        });
    }
}

Metadata

Metadata

Assignees

Labels

area/docsImprovements or additions to documentationkind/enhancementImprovements or new featuresresolution/fixedThis issue was fixed

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions