sparse-intern-71089
02/27/2020, 5:32 PMtall-librarian-49374
02/28/2020, 7:27 AMInputMap because it may contain unresolved values. EcsServiceResourceOptions is a class of yours, right? If so, you could make EnvironmentVariables just a normal C# dictionary and iterate through it. Alternatively, you’d need to use Apply on InputMap and do the processing inside. However, creating resources inside Apply should generally be avoided.straight-flower-13757
02/28/2020, 8:12 AMEcsServiceResourceOptions correct, it’s mine
Thanks for the suggestion on using dictionarystraight-flower-13757
02/28/2020, 6:41 PMarn of the ssm parameter like:
public class EcsService : ComponentResource
{
public EcsService(string name, EcsServiceResourceOptions options)
: base("foo:pulumi:ecs", name, options)
{
...
var parameters = new List<Pulumi.Aws.Ssm.Parameter>();
foreach (var variable in options.EnvironmentVariables)
{
var Parameter = new Pulumi.Aws.Ssm.Parameter(variable.Key,
...
, new CustomResourceOptions { Parent = this });
parameters.Add(Parameter);
}
...
var taskInlineRoleDocument = Pulumi.Aws.Iam.Invokes.GetPolicyDocument(new Pulumi.Aws.Iam.GetPolicyDocumentArgs
{
Statements = {
new Pulumi.Aws.Iam.Inputs.GetPolicyDocumentStatementsArgs {
Effect = "Allow",
Resources = parameters.Select(_=>_.Arn.Apply(arn => arn)).ToList(), //what to do here to await all parameters to be created, and then extract their arns ?
Actions = { "ssm:GetParameters", "ssm:GetParameter" }
}
}
}
});
...
}
}
I’m finding it hard to create dynamic resources, can we have more examples were we create multiple resources and then feed them into another resource like the above example
Thank in advance !tall-librarian-49374
02/29/2020, 8:53 PM.Apply(arn => arn) does nothing. You can’t await outputs. Instead, you could convert a list of outputs to an output of list with Output.All, however this means that you have to make your GetPolicyDocument call inside an Apply.straight-flower-13757
03/02/2020, 8:05 AMtall-librarian-49374
03/02/2020, 8:33 AMstraight-flower-13757
03/02/2020, 9:15 AMvar taskInlineRoleDocument = Output.All<string>(parameters.Select(_ => _.Arn).Cast<Input<string>>().ToArray())
.Apply(async list =>
{
return await Pulumi.Aws.Iam.Invokes.GetPolicyDocument(new Pulumi.Aws.Iam.GetPolicyDocumentArgs
{
Statements =
{
new Pulumi.Aws.Iam.Inputs.GetPolicyDocumentStatementsArgs {
Effect = "Allow",
Resources = list.ToList(),
Actions = { "ssm:GetParameters", "ssm:GetParameter" }
},
}
});
});
But I’m getting `System.InvalidCastException: Unable to cast object of type ‘Pulumi.Output`1[System.String]’ to type ’Pulumi.Input`1[System.String]. `
my understanding that assignable should mean castable.straight-flower-13757
03/02/2020, 9:16 AMstraight-flower-13757
03/02/2020, 9:29 AMOutput.All<string>(parameters.Select(_ => (Input<string>)_.Arn).ToArray())tall-librarian-49374
03/02/2020, 9:42 AMCast doesn’t work with implicit/explicit conversions https://stackoverflow.com/questions/13316718/explicit-implicit-cast-operator-fails-when-using-linqs-cast-operatortall-librarian-49374
03/02/2020, 9:44 AMOutput.All(outputs)straight-flower-13757
03/02/2020, 9:50 AM