https://pulumi.com logo
Title
s

stocky-petabyte-29883

03/31/2022, 12:43 PM
Hi I am trying to export outputs from resources created inside a loop using typescript. However the accountOutput is always empty. I am wondering whats the right approach to do this.
let accountDetails = [
    {name: 'test', email: '<mailto:testt@example.io|testt@example.io>', environment: 'test', billingInfoAccess: 'ALLOW'}
];

var accountOutput: { accountName: string, accountId: string }[] = [];

for (const accountDetail of accountDetails) {
    const account = new aws.organizations.Account(accountDetail.name, {
        email: accountDetail.email,
        iamUserAccessToBilling: accountDetail.billingInfoAccess,
        name: accountDetail.name,
        tags: {
            Environment: accountDetail.environment
        },
    });

    account.arn.apply(arn => {
        console.log(arn);
        accountOutput.push({accountName: accountDetail.name, accountId: arn})
    })
};


export const outputs = {
    accountInfo: accountOutput,
}