Search code examples
c#pulumi

Pulumi C#: mark stack output as a secret


I'm creating an ACR that will be shared with several stacks and I need the information in the output

How can I protect the password output?

using Pulumi;
using Pulumi.Azure.Core;
using Pulumi.Azure.ContainerService;

class MyStack : Stack
{
    public MyStack()
    {
        string baseName = $"{Deployment.Instance.ProjectName}-{Deployment.Instance.StackName}";
        string restrictedName = baseName.ToLower().Replace("-", "");

        var resourceGroup = new ResourceGroup("resourceGroup", new ResourceGroupArgs
        {
            Name = baseName
        });

        var acr = new Registry("myorg-acr", new RegistryArgs
        {
            Name = $"{restrictedName}acr",
            ResourceGroupName = resourceGroup.Name,
            Sku = "Basic",
            AdminEnabled = true
        });

        AcrLoginServer = acr.LoginServer;
        AcrAdminUsername = acr.AdminUsername;
        AcrAdminPassword = acr.AdminPassword;
    }

    [Output]
    public Output<string> AcrLoginServer { get; private set; }
    [Output]
    public Output<string> AcrAdminUsername { get; private set; }
    [Output]
    public Output<string> AcrAdminPassword { get; private set; }
}

Solution

  • You should be able to mark an output as secret like this:

    AcrAdminPassword = registry.AdminPassword.Apply(Output.CreateSecret);