There's a way to create a Pulumi `gcp.serviceaccou...
# general
b
There's a way to create a Pulumi
gcp.serviceaccount.IAMMember
that accepts multiple roles like from a list like this
['roles/iam.serviceAccountUser', 'roles/storage.admin']
? Using typescript btw. Every time I try to add something like that I see this error. But I would like to have a module it can be reused, and providing a list I can reuse that for many purposes.
Copy code
error: gcp:serviceaccount/iAMMember:IAMMember resource 'prod-sa-runner' has a problem: Attribute must be a single value, not a list. Examine values at 'prod-sa-runner.role'.
d
You can iterate over the list to create multiple IAMMember resources
b
Can you give me and example how to do it? Because I tried like that and couldn't
d
Something like..
Copy code
roles.forEach(r => IAMMember(`prod-sa-runner-${r}`, {
  role: r,
  serviceAccountId: sa.id,
 ...
});
For the resource name, you'll need to slugify the role being passed in to avoid special characters like ':' and '/'
b
Got it, I'll try. Thanks