straight-flower-13757
02/22/2020, 4:51 AMComponentResource
I have something similar to this in the Deployment.RunAsync
like
return Deployment.RunAsync(async () =>
{
var assumeRoleDocument = await Pulumi.Aws.Iam.Invokes.GetPolicyDocument(new Pulumi.Aws.Iam.GetPolicyDocumentArgs
{
Statements = {
...
}
}
});
var ecsPolicyRole = new Pulumi.Aws.Iam.Role($"{name}-ecs-role", new Pulumi.Aws.Iam.RoleArgs
{
AssumeRolePolicy = assumeRoleDocument.Json
});
});
Now I’m trying to move that into a dedicated module, using ComponentResource
What is your recommendation for doing that since I can’t await in the constructor of the custom ComponentResource
?
I did this hack, but not sure if I’m missing something that will make it more straight forward:
public class EcsService : ComponentResource
{
public EcsService(string name, EcsServiceResourceOptions options)
: base("foo:pulumi:ecs", name, options)
{
var assumeRoleDocument = Pulumi.Aws.Iam.Invokes.GetPolicyDocument(new Pulumi.Aws.Iam.GetPolicyDocumentArgs
{
Statements = {
...
}
}
});
var ecsPolicyRole = new Pulumi.Aws.Iam.Role($"{name}-ecs-role", new Pulumi.Aws.Iam.RoleArgs
{
AssumeRolePolicy = Output.Create("").Apply(async _ => (await assumeRoleDocument).Json) //getting advantage of the built in Output type and its Apply func
}, new CustomResourceOptions { Parent = this });
}
}
tall-librarian-49374
02/22/2020, 8:26 PMAssumeRolePolicy = Output.Create(assumeRoleDocument).Apply(v => v.Json)
Output.Create
has an overload accepting a task.straight-flower-13757
02/23/2020, 5:24 AM