Skip to content

Commit 7bafd1c

Browse files
fix(core): Fixing remove account or Leave from organization action trigger (#618)
* Fixing remove account action * Changing Config for suspended accounts * Update ou-validation with suspended account fix
1 parent 7505aa1 commit 7bafd1c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/core/runtime/src/ou-validation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { JSON_FORMAT, YAML_FORMAT } from '@aws-accelerator/common/src/util/const
1212
import { DynamoDB } from '@aws-accelerator/common/src/aws/dynamodb';
1313
import { getItemInput } from './utils/dynamodb-requests';
1414

15+
const SUSPENDED_OU_NAME = 'Suspended';
16+
1517
export interface ValdationInput extends LoadConfigurationInput {
1618
acceleratorPrefix: string;
1719
parametersTableName: string;
@@ -221,10 +223,9 @@ export const handler = async (input: ValdationInput): Promise<string> => {
221223
rootAccountIds = rootAccountIds.filter(acc => acc !== rootMasterAccount?.Id!);
222224
}
223225
}
224-
const suspendedOuName = 'Suspended';
225-
let suspendedOu = awsOusWithPath.find(o => o.Path === suspendedOuName);
226+
let suspendedOu = awsOusWithPath.find(o => o.Path === SUSPENDED_OU_NAME);
226227
if (!suspendedOu) {
227-
suspendedOu = await createSuspendedOu(suspendedOuName, rootId);
228+
suspendedOu = await createSuspendedOu(SUSPENDED_OU_NAME, rootId);
228229
awsOusWithPath.push(suspendedOu);
229230
}
230231

src/lib/common/src/util/common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,15 @@ export function equalIgnoreCase(value1: string, value2: string): boolean {
149149
export async function loadAccounts(tableName: string, client: DynamoDB): Promise<Account[]> {
150150
let index = 0;
151151
const accounts: Account[] = [];
152+
if (!client) {
153+
client = new DynamoDB();
154+
}
152155
while (true) {
153156
const itemsInput = {
154157
TableName: tableName,
155158
Key: { id: { S: `accounts/${index}` } },
156159
};
157-
const item = await new DynamoDB().getItem(itemsInput);
160+
const item = await client.getItem(itemsInput);
158161
if (index === 0 && !item.Item) {
159162
throw new Error(`Cannot find parameter with ID "accounts"`);
160163
}

0 commit comments

Comments
 (0)