in packages/apps/core/app/lib/app.ts [78:178]
constructor(props: MdaaAppProps, packageNameVersion?: MdaaPackageNameVersion) {
super(props);
this.node.setContext('aws-cdk:enableDiffNoFail', true);
this.node.setContext('@aws-cdk/core:enablePartitionLiterals', true);
assert(this.node.tryGetContext('org'), "Organization must be specified in context as 'org'");
assert(this.node.tryGetContext('env'), "Environment must be specified in context as 'env'");
assert(this.node.tryGetContext('domain'), "Domain must be specified in context as 'domain'");
assert(this.node.tryGetContext('module_name'), "Module Name must be specified in context as 'module_name'");
this.org = this.node.tryGetContext('org').toLowerCase();
this.env = this.node.tryGetContext('env').toLowerCase();
this.domain = this.node.tryGetContext('domain').toLowerCase();
this.moduleName = this.node.tryGetContext('module_name').toLowerCase();
// Solution Details
this.solutionId = pjson.solution_id;
this.solutionName = pjson.solution_name;
this.solutionVersion = pjson.version;
const packageName = packageNameVersion?.name.replace('@aws-mdaa/', '') ?? 'unknown';
const packageVersion = packageNameVersion?.version ?? 'unknown';
console.log(`Running MDAA Module ${packageName} Version: ${packageVersion}`);
if (this.node.tryGetContext('@aws-mdaa/legacyCaefTags')) {
this.tags = {
caef_org: this.org,
caef_env: this.env,
caef_domain: this.domain,
caef_cdk_app: packageName,
caef_module_name: this.moduleName,
};
} else {
this.tags = {
mdaa_org: this.org,
mdaa_env: this.env,
mdaa_domain: this.domain,
mdaa_cdk_app: packageName,
mdaa_module_name: this.moduleName,
};
}
if (props.useBootstrap != undefined) {
this.useBootstrap = props.useBootstrap;
} else {
this.useBootstrap =
this.node.tryGetContext('use_bootstrap') == undefined
? true
: /true/i.test(this.node.tryGetContext('use_bootstrap'));
}
const namingModule: string = this.node.tryGetContext('naming_module');
const namingClass: string = this.node.tryGetContext('naming_class');
this.naming = this.configNamingModule(namingModule, namingClass);
const logSuppressions: boolean =
this.node.tryGetContext('log_suppressions') == undefined
? false
: /true/i.test(this.node.tryGetContext('log_suppressions'));
Aspects.of(this).add(new AwsSolutionsChecks({ verbose: true, logIgnores: logSuppressions }));
Aspects.of(this).add(new NIST80053R5Checks({ verbose: true, logIgnores: logSuppressions }));
Aspects.of(this).add(new HIPAASecurityChecks({ verbose: true, logIgnores: logSuppressions }));
Aspects.of(this).add(new PCIDSS321Checks({ verbose: true, logIgnores: logSuppressions }));
this.applyCustomAspects();
this.appConfigRaw = {
...this.loadConfigFromFiles(this.node.tryGetContext('module_configs')?.split(',') || []),
...this.loadAppConfigDataFromContext(),
...props.appConfigRaw,
};
this.tags = { ...this.loadTagConfigFromFiles(), ...this.loadTagConfigDataFromContext(), ...this.tags };
this.deployAccount = process.env.CDK_DEPLOY_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT;
this.deployRegion = process.env.CI_SUPPLIED_TARGET_REGION || process.env.CDK_DEFAULT_REGION;
this.additionalAccounts = this.node.tryGetContext('additional_accounts')?.split(',');
this.stack = this.createEmptyStack();
this.additionalAccountStacks = Object.fromEntries(
this.additionalAccounts?.map(account => {
const stackName = this.naming.stackName(account);
const stackProps = {
naming: this.naming,
env: {
region: this.stack.region,
account: account,
},
};
const additionalAccountStack = new Stack(this, stackName, stackProps);
additionalAccountStack.addDependency(this.stack);
return [account, additionalAccountStack];
}) || [],
);
this.baseConfigParser = new MdaaAppConfigParser<MdaaBaseConfigContents>(
this.stack,
this.getConfigParserProps(),
configSchema,
undefined,
true,
);
}