crooked-helmet-6159
04/19/2024, 2:26 PMtypescript
...
const accounts =
someJsons.map((out: any) =>
({
...out,
// Explicit providers
// <https://www.pulumi.com/docs/concepts/resources/providers/>
account: new cloudflare.Provider(out.account_id, { apiToken: out.account_token })
}));
const buckets =
accounts.map((out: any) =>
({
...out,
bucket: new cloudflare.R2Bucket(`r2-${out.bucket_name}`, {
accountId: out.account_id,
name: out.bucket_name,
location: out.bucket_location,
}, { provider: out.account }),
allPms: cloudflare.getApiTokenPermissionGroups({ provider: out.account })
}));
...
Where I import a JSON with array where each element has one S3 bucket name and a Cloudflare account ID where this bucket should be created. It works great unless they're two buckets in the same account since account: new cloudflare.Provider(out.account_id
throws an error when re-using the same accountId
.
I need to write some condition that checks if the account was already used and then return it's object or create a new object if the account hasn't been created yet.
Could you please help me how to do that?
Thank you.echoing-dinner-19531
04/21/2024, 7:48 AM