Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/aws-cdk-lib/aws-iam/lib/principals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ export class ArnPrincipal extends PrincipalBase {
*/
export class AccountPrincipal extends ArnPrincipal {
public readonly principalAccount: string | undefined;
private accountIdRegExp = new RegExp('^[0-9]{12}$');

/**
*
Expand All @@ -481,6 +482,10 @@ export class AccountPrincipal extends ArnPrincipal {
if (!cdk.Token.isUnresolved(accountId) && typeof accountId !== 'string') {
throw new Error('accountId should be of type string');
}
if (!this.accountIdRegExp.test(accountId)) {
/* eslint-disable-next-line no-console */
console.warn('accountId should be a 12-digit number');
}
this.principalAccount = accountId;
}

Expand Down
Loading