wet-noon-14291
01/11/2022, 9:48 PMComponentResource
? We struggle with having a stack hanging if the async requests fails. We are doing something like this:
export class Team extends pulumi.ComponentResource {
teamId: pulumi.Output<string>
constructor(name: string, teamSpec: types.TeamSpec) {
super("something", name, {});
const azureAdConfig = azuread.getClientConfig({})
const usersIds = pulumi.output(getUsers(teamSpec.members)); // getUsers is something that returns a promise
const adGroup = new azuread.Group(`${teamSpec.teamName}-ad-group`, {
displayName: teamSpec.teamName,
owners: [azureAdConfig.then(c => c.objectId)],
description: "Created and managed by Automation",
securityEnabled: true,
members: usersIds
});
....
if the call to getUsers
fails everything will just hang. I would expect pulumi to catch that and fail the whole process. Am I doing something wrong or is this a bug?little-cartoon-10569
01/11/2022, 9:53 PMwet-noon-14291
01/11/2022, 9:55 PMlittle-cartoon-10569
01/11/2022, 9:56 PMgetUsers()
resolve anything outside of the Promise? If everything is deferred until the Pulumi engine is doing its thing, you should be okay.wet-noon-14291
01/11/2022, 9:58 PMconst getUsers = async (members: string[]) => {
const users = await azuread.getUsers(
{
userPrincipalNames: members
}
)
return users.objectIds;
}
little-cartoon-10569
01/11/2022, 9:58 PMthen()
instead of an async/await block.wet-noon-14291
01/11/2022, 9:59 PMlittle-cartoon-10569
01/11/2022, 10:00 PMwet-noon-14291
01/11/2022, 10:00 PMlittle-cartoon-10569
01/11/2022, 10:01 PMpulumi.output(azuread.getUsers({ userPrincipalNames: members}).then(u => u.objectIds))
pulumi.output(azuread.getUsers({ userPrincipalNames: members})).apply(u => u.objectIds)
wet-noon-14291
01/11/2022, 10:05 PMlittle-cartoon-10569
01/12/2022, 7:32 PMwet-noon-14291
01/12/2022, 9:59 PM