o
g
given the
[object Object]
in the error, I think you need to tell Pulumi to transform the sa's outputs to the new string
e.g.
Copy code
pulumi.interpolate`${project}:${role}:${sa.email}`
and
Copy code
pulumi.interpolate`serviceAccount:${sa.email}`
o
where do I run the transform - doesn't like it inline
g
no? I've used it inline a lot I think. 😕
it's a relatively new addition to pulumi - in 0.16.11 a couple weeks ago in case you're on a version older than that
o
I'm on 0.16.12
see photo
g
I see. Trying some things... brb
So the issue is that the resource name requires a
string
all other arguments require
pulumi.Input<String>
. Pulumi needs the resource name "early" to ensure uniqueness so it can't depend on any
Output
values.
so using
pulumi.interpolate...
on the
member
value will work
but we'll need to compose an actual string for the resource name
so something like this :
Copy code
typescript
export function createIamMemberFromServiceAccount(
    roles: string[],
    members: gcp.serviceAccount.Account[],
    project: string
) {
    roles.forEach(role => {
        members.forEach((sa, idx) => {
            new gcp.projects.IAMMember(`${project}:${role}-${idx}`, {
                member: pulumi.interpolate`serviceAccount:${sa.email}`,
                project,
                role
            });
        });
    });
}
from what I can tell, the name for an IAMMember only matters for Pulumi's needs, not GCP's. GCP never sees it.
Was that able to work for you?