Does anyone know how to pass variables in a local ...
# general
m
Does anyone know how to pass variables in a local Command (from Pulumi Command package). Should they be passed as environment variables or directly used using string interpolation? When I am using variables from resources previously created, the command fails. when I use hard coded string the command works. Here is my code in case it helps to understand my problem:
var sqlServer = new Server($"sql-sqlDbWithAzureAd-{Deployment.Instance.StackName}", new ServerArgs
{
   
ResourceGroupName = resourceGroup.Name,
   
Administrators = new ServerExternalAdministratorArgs
   
{
       
Login = sqlAdAdmin.UserPrincipalName,
       
Sid = sqlAdAdmin.Id,
       
AzureADOnlyAuthentication = true,
       
AdministratorType = AdministratorType.ActiveDirectory,
       
PrincipalType = PrincipalType.User,
   
},
});
var database = new Database("sqldb-sqlDbWithAzureAd-Main", new DatabaseArgs
{
   
ResourceGroupName = resourceGroup.Name,
   
ServerName = sqlServer.Name,
   
Sku = new SkuArgs
   
{
       
Name = "Basic"
   
}
});
var authorizeAdGroup = new Command("AuthorizeAdGroup", new CommandArgs
{
     
Create = $"sqlcmd -S {sqlServer.Name} -?",
     
Interpreter = new InputList<string>
     
{
         
"pwsh",
         
"-c"
     
}
 
}, new CustomResourceOptions
 
{
     
DependsOn = new InputList<Pulumi.Resource> { enableLocalMachine, database, sqlServer }
 
});
l
Looks like your Create property is using simple interpolation instead of Pulumi interpolation.
sqlServer.Name
isn't a string, it's a string output, so you need handle it as such. I presume that Pulumi golang has an equivalent of the typescript pulumi.interpolate? It takes interpolates a string output into a string and returns a string output that can be used in most Pulumi resource constructors.
🙏 1