Skip to content

Commit 68b716b

Browse files
shorten generated KMS SA name if > 30 characters (#2679) (#2682)
Signed-off-by: Stephen Compall <stephen.compall@digitalasset.com>
1 parent 32473b0 commit 68b716b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

cluster/pulumi/common/src/participantKms.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const createKmsServiceAccount = (
3333
};
3434
const serviceAccountName = migrationIdSuffixed(
3535
`${CLUSTER_BASENAME}-${xns.logicalName}-kms`,
36-
migrationId
36+
migrationId,
37+
true
3738
);
3839
const kmsServiceAccount = new GcpServiceAccount(serviceAccountName, {
3940
accountId: serviceAccountName,
@@ -109,5 +110,16 @@ export const getParticipantKmsHelmResources = (
109110
};
110111
};
111112

112-
const migrationIdSuffixed = (name: string, migrationId?: DomainMigrationIndex) =>
113-
migrationId != undefined ? `${name}-migration-${migrationId}` : name;
113+
function migrationIdSuffixed(
114+
name: string,
115+
migrationId?: DomainMigrationIndex,
116+
limit30?: boolean
117+
): string {
118+
if (migrationId === undefined) {
119+
return name;
120+
}
121+
const longName = `${name}-migration-${migrationId}`;
122+
// error: gcp:serviceaccount/account:Account
123+
// resource..."account_id"...must be between 6 and 30 characters long
124+
return limit30 && longName.length > 30 ? `${name}-mg-${migrationId}` : longName;
125+
}

0 commit comments

Comments
 (0)