From the pulumi docs for creating a global dynamo table, creating the global table depends on the replica tables being created first. My Pulumi project is in an asynchronous typescript environment, and I'm creating the replica tables inside the function below.
const replicaTables: any[] = [];
pulumi
.all([createAwsProvidersInAllRegions(accountsConfig)])
.apply(async ([providers]) => {
return providers.map(({ provider, regionName, vpcId, subnets }) => {
// create replica tables here
const regionalReplicaTable = createReplicaTable();
replicaTables.push(regionalReplicaTable);
});
});
I'm trying to create the global table in the code below.
new aws.dynamodb.GlobalTable(`${namespace}-deviceInfo-global`, {replicas: replicaTables},
{
dependsOn: replicaTables,
},
But the replicaTables
array is empty at the time this code runs due to the asynchronous nature of the node environment. How do I ensure that the replicaTables
array is filled with the replica tables at the time the code to create the global table runs?