Hi all, Still very new to the pulumi environment,...
# dotnet
a
Hi all, Still very new to the pulumi environment, looking for insight into why this isn't working and the right way to do approach this. I assume it is tied to a misunderstanding of .Apply() We have created a custom component that accepts a few inputs, most are just Input<string>, one of them is an InputMap<string>. I'd like to pass the value of an output<string> earlier on in the deployment to the value of one of the InputMap<string> items but I get the
System.InvalidOperationException: Operation is not valid due to the current state of the object.
exception. I can pass the output<string> value to any of the Input<strings> as expected. I can hardcode the InputMap<string> values without issue. Example:
Copy code
//Entra App registration, outputs a ClientId
var appRegistration = new AzureAd.Application("testApp", new()
{
    DisplayName = $"test-app",
    Description = "testapp",
    SignInAudience = "AzureADMyOrg",
    IdentifierUris = new[]
    {
        "<api://testapp>"
    }
}

var customComponent = new CustomComponent("testcustom", new()
    {
        Name = appRegistration.ClientId //This works
        EnvironmentVariables = new InputMap<string>()
        {
            { "EntraId__ClientId", appRegistration.ClientId } //this throws the error. 
        }
    }

//I've also tried this to no success

var customComponent = new CustomComponent("testcustom", new()
    {
        Name = appRegistration.ClientId //This works
        EnvironmentVariables = new InputMap<string>()
        {
            { "EntraId__ClientId", appRegistration.ClientId.Apply(val => val) } //this throws the error. 
        }
    }

//And this
var clientIdDict = appRegistration.ClientId.Apply(clientId =>
{
    return new Dictionary<string, string>()
    {
        {"EntraId__ClientId", clientId}
    };
});

var customComponent = new CustomComponent("testcustom", new()
    {
        Name = appRegistration.ClientId //This works
        EnvironmentVariables = clientIdDict //This doesn't work
    }
e
oh that's odd, I'd expect that to work ok. Won't have time today but I can look into this tomorrow.
What is
CustomComponent
doing with the EnvironmentVariables property? I can't repro an InvalidOperationException with just doing basic things with InputMap.