Skip to content

Commit 5773ba5

Browse files
authored
fixed missing vpc config section (#941)
* fixed missing vpc config section * throw an error if manditory section missing * fixed typo Co-authored-by: hickeydh-aws <hickeydh@amazon.com>
1 parent fcd30f3 commit 5773ba5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,13 @@ export async function vpcReplacements(props: { rawConfigStr: string }): Promise<
269269
const ouOrAccountReplacementRegex = '\\${CONFIG::OU_NAME}';
270270
const vpcConfigSections = ['workload-account-configs', 'mandatory-account-configs', 'organizational-units'];
271271
const rawConfig = JSON.parse(rawConfigStr);
272-
for (const vpcConfigSection of vpcConfigSections) {
272+
const existingVpcConfigSections = vpcConfigSections.filter(vpcConfigSection => rawConfig[vpcConfigSection]);
273+
if (existingVpcConfigSections.length < vpcConfigSections.length) {
274+
console.log('Expected the following keys to exist', vpcConfigSections);
275+
console.log('Only found the following keys', existingVpcConfigSections);
276+
throw new Error('Please add the missing manditory sections to the configuration file.');
277+
}
278+
for (const vpcConfigSection of existingVpcConfigSections) {
273279
Object.entries(rawConfig[vpcConfigSection]).map(([key, _]) => {
274280
const replacements = {
275281
'\\${CONFIG::VPC_NAME}': key,

0 commit comments

Comments
 (0)