in packages/cli/lib/mdaa-cli.ts [673:741]
private createCdkCommand(moduleEffectiveConfig: ModuleEffectiveConfig, localModule: boolean): string {
const action = this.action == 'deploy' ? `${this.action} --all` : this.action;
const cdkEnv: string[] = this.createCdkCommandEnv(moduleEffectiveConfig);
const cdkCmd: string[] = [];
cdkCmd.push(
`npx ${this.npmDebug ? '-d' : ''} cdk ${action} ${this.cdkVerbose ? '-v' : ''} --require-approval never`,
);
if (!localModule) {
cdkCmd.push(`-a 'npx ${this.npmDebug ? '-d' : ''} ${moduleEffectiveConfig.modulePath}/'`);
}
cdkCmd.push(
`-o '${this.workingDir}/cdk.out/${this.config.contents.organization}/${moduleEffectiveConfig.domainName}/${moduleEffectiveConfig.envName}/${moduleEffectiveConfig.moduleName}'`,
);
cdkCmd.push(`-c 'org=${this.config.contents.organization}'`);
cdkCmd.push(`-c 'env=${moduleEffectiveConfig.envName}'`);
cdkCmd.push(`-c 'module_name=${moduleEffectiveConfig.moduleName}'`);
cdkCmd.push(`-c 'domain=${moduleEffectiveConfig.domainName}'`);
if (this.config.contents.naming_module && this.config.contents.naming_class) {
cdkCmd.push(`-c 'naming_module=${moduleEffectiveConfig.customNaming?.naming_module}'`);
cdkCmd.push(`-c 'naming_class=${moduleEffectiveConfig.customNaming?.naming_class}'`);
} else if (this.config.contents.naming_module || this.config.contents.naming_class) {
throw new Error("Both 'naming_module' and 'naming_class' must be specified together.");
}
this.addOptionalCdkContextStringParam(cdkCmd, 'use_bootstrap', moduleEffectiveConfig.useBootstrap?.toString());
this.addOptionalCdkContextStringParam(
cdkCmd,
'module_configs',
moduleEffectiveConfig.moduleConfigFiles?.map(x => path.resolve(x)).join(','),
);
this.addOptionalCdkContextStringParam(
cdkCmd,
'tag_configs',
moduleEffectiveConfig.tagConfigFiles?.map(x => path.resolve(x)).join(','),
);
this.addOptionalCdkContextStringParam(
cdkCmd,
'additional_accounts',
moduleEffectiveConfig.additionalAccounts?.join(','),
);
this.addOptionalCdkContextStringParam(
cdkCmd,
'log_suppressions',
this.config.contents.log_suppressions?.toString(),
);
this.addOptionalCdkContextObjParam(cdkCmd, 'custom_aspects', moduleEffectiveConfig.customAspects);
this.addOptionalCdkContextObjParam(cdkCmd, 'module_config_data', moduleEffectiveConfig.effectiveModuleConfig);
this.addOptionalCdkContextObjParam(cdkCmd, 'tag_config_data', moduleEffectiveConfig.effectiveTagConfig);
if (this.roleArn) {
cdkCmd.push(`-r '${this.roleArn}'`);
}
cdkCmd.push(...generateContextCdkParams(moduleEffectiveConfig));
if (this.cdkPushdown) {
console.log(
`Module ${moduleEffectiveConfig.domainName}/${moduleEffectiveConfig.envName}/${
moduleEffectiveConfig.moduleName
}: CDK Pushdown Options: ${JSON.stringify(this.cdkPushdown, undefined, 2)}`,
);
cdkCmd.push(...this.cdkPushdown);
}
return cdkEnv.length > 0 ? `${cdkEnv.join(' && ')} && ${cdkCmd.join(' \\\n\t')}` : cdkCmd.join(' \\\n\t');
}