Skip to content

Commit 9fe97a1

Browse files
dspclaude
andcommitted
fix: create OrgUnit resource before provisioning GWS users
The orgUnitPath '/Model Context Protocol' was hardcoded but the OU didn't exist in Pulumi state, causing INVALID_OU_ID errors for all user creates/updates. Create it as a Pulumi resource and wire up dependsOn so users are provisioned after the OU exists. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b1c85af commit 9fe97a1

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

src/google.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ ROLES.forEach((role: Role) => {
4848
});
4949
});
5050

51+
// Create the organizational unit for MCP users
52+
const mcpOrgUnit = new gworkspace.OrgUnit('mcp-org-unit', {
53+
name: 'Model Context Protocol',
54+
parentOrgUnitPath: '/',
55+
description: 'Organizational unit for MCP team members (Managed by github.com/modelcontextprotocol/access)',
56+
});
57+
5158
// Provision Google Workspace user accounts for members in roles with provisionUser
5259
const provisionedUsersByEmail: Record<string, gworkspace.User> = {};
5360
const newUserPasswords: Record<string, pulumi.Output<string>> = {};
@@ -76,9 +83,9 @@ MEMBERS.forEach((member) => {
7683
{
7784
primaryEmail,
7885
name: { familyName: member.lastName!, givenName: member.firstName! },
79-
orgUnitPath: '/Model Context Protocol',
86+
orgUnitPath: mcpOrgUnit.orgUnitPath,
8087
},
81-
{ import: primaryEmail }
88+
{ import: primaryEmail, dependsOn: [mcpOrgUnit] }
8289
);
8390
provisionedUsersByEmail[primaryEmail] = user;
8491
} else {
@@ -91,14 +98,18 @@ MEMBERS.forEach((member) => {
9198
crypto.createHash('sha1').update(plaintext).digest('hex')
9299
);
93100

94-
const user = new gworkspace.User(`gws-user-${member.googleEmailPrefix}`, {
95-
primaryEmail,
96-
name: { familyName: member.lastName!, givenName: member.firstName! },
97-
password: hashedPassword,
98-
hashFunction: 'SHA-1',
99-
changePasswordAtNextLogin: true,
100-
orgUnitPath: '/Model Context Protocol',
101-
});
101+
const user = new gworkspace.User(
102+
`gws-user-${member.googleEmailPrefix}`,
103+
{
104+
primaryEmail,
105+
name: { familyName: member.lastName!, givenName: member.firstName! },
106+
password: hashedPassword,
107+
hashFunction: 'SHA-1',
108+
changePasswordAtNextLogin: true,
109+
orgUnitPath: mcpOrgUnit.orgUnitPath,
110+
},
111+
{ dependsOn: [mcpOrgUnit] }
112+
);
102113
provisionedUsersByEmail[primaryEmail] = user;
103114

104115
// Track password for export so an admin can retrieve it

0 commit comments

Comments
 (0)