private createDomain()

in packages/constructs/L3/ai/sm-studio-domain-l3-construct/lib/sm-studio-domain-l3-construct.ts [322:409]


  private createDomain(
    defaultExecutionRole: IRole,
    securityGroup: ISecurityGroup,
    kmsKey: IKey,
    domainBucket: IBucket,
    assetPrefix: string,
    assetDeploymentRole: IRole,
    assetDeploymentMemoryLimitMB?: number,
  ): MdaaStudioDomain {
    const jupyterLifecycleConfig = this.props.domain.lifecycleConfigs?.jupyter
      ? this.createStudioLifecycleConfig(
          this.props.domain.lifecycleConfigs.jupyter,
          'JupyterServer',
          domainBucket,
          assetPrefix,
          assetDeploymentRole,
          assetDeploymentMemoryLimitMB,
        )
      : undefined;

    const kernelLifecycleConfig = this.props.domain.lifecycleConfigs?.kernel
      ? this.createStudioLifecycleConfig(
          this.props.domain.lifecycleConfigs.kernel,
          'KernelGateway',
          domainBucket,
          assetPrefix,
          assetDeploymentRole,
          assetDeploymentMemoryLimitMB,
        )
      : undefined;

    if (jupyterLifecycleConfig && kernelLifecycleConfig) {
      kernelLifecycleConfig.node.addDependency(jupyterLifecycleConfig);
    }

    const jupyterServerAppSettings = jupyterLifecycleConfig
      ? {
          defaultResourceSpec: {
            lifecycleConfigArn: jupyterLifecycleConfig.arn,
          },
          lifecycleConfigArns: [jupyterLifecycleConfig.arn],
        }
      : undefined;

    const kernelGatewayAppSettings = kernelLifecycleConfig
      ? {
          defaultResourceSpec: {
            lifecycleConfigArn: kernelLifecycleConfig.arn,
          },
          lifecycleConfigArns: [kernelLifecycleConfig.arn],
        }
      : undefined;

    const defaultUserSettingsWithLifecycle: CfnDomain.UserSettingsProperty = {
      executionRole: defaultExecutionRole.roleArn,
      jupyterServerAppSettings: jupyterServerAppSettings,
      kernelGatewayAppSettings: kernelGatewayAppSettings,
    };
    // nosemgrep
    const _ = require('lodash');
    function customizer(objValue: unknown[], srcValue: unknown): void | unknown[] {
      if (_.isArray(objValue)) {
        return objValue.concat(srcValue);
      }
    }

    const defaultUserSettings: CfnDomain.UserSettingsProperty = _.mergeWith(
      this.props.domain.defaultUserSettings,
      defaultUserSettingsWithLifecycle,
      customizer,
    );

    const domainProps = {
      authMode: this.props.domain.authMode,
      vpcId: this.props.domain.vpcId,
      subnetIds: this.props.domain.subnetIds,
      kmsKeyId: kmsKey.keyId,
      defaultUserSettings: defaultUserSettings,
      naming: this.props.naming,
      securityGroupId: securityGroup.securityGroupId,
      executionRole: defaultExecutionRole,
    };

    const domain = new MdaaStudioDomain(this, 'domain', domainProps);
    if (jupyterLifecycleConfig) domain.node.addDependency(jupyterLifecycleConfig);
    if (kernelLifecycleConfig) domain.node.addDependency(kernelLifecycleConfig);
    return domain;
  }