constructor()

in packages/constructs/L2/datazone-constructs/lib/index.ts [42:114]


  constructor(scope: Construct, id: string, props: MdaaDatazoneProjectProps) {
    super(scope, id);

    const domainConfigParser = props.domainConfigSSMParam
      ? MdaaDatazoneProject.createSsmDomainConfigParser(scope, props.naming, props.domainConfigSSMParam)
      : undefined;

    const domainArn = props.domainArn || domainConfigParser?.getAttString('domainArn');
    if (!domainArn) throw new Error('domainArn must either be defined directly in props, or via domainConfigSSMParam');
    this.domainArn = domainArn;

    const domainVersion = props.domainVersion || domainConfigParser?.getAttString('domainVersion');
    if (!domainVersion)
      throw new Error('domainVersion must either be defined directly in props, or via domainConfigSSMParam');
    this.domainVersion = domainVersion;

    const domainId = props.domainId || domainConfigParser?.getAttString('domainId');
    if (!domainId) throw new Error('domainId must either be defined directly in props, or via domainConfigSSMParam');
    this.domainId = domainId;

    const domainCustomEnvBlueprintId =
      props.domainCustomEnvBlueprintId || domainConfigParser?.getAttString('datalakeEnvBlueprintId');
    if (!domainCustomEnvBlueprintId)
      throw new Error(
        'domainCustomEnvBlueprintId must either be defined directly in props, or via domainConfigSSMParam',
      );
    this.domainCustomEnvBlueprintId = domainCustomEnvBlueprintId;

    const datalakeManagementRoleArn =
      props.datalakeManagementRoleArn || domainConfigParser?.getAttString('datalakeManagementRoleArn');
    if (!datalakeManagementRoleArn)
      throw new Error(
        'datalakeManagementRoleArn must either be defined directly in props, or via domainConfigSSMParam',
      );
    this.datalakeManagementRoleArn = datalakeManagementRoleArn;

    const adminUserProfileId = props.adminUserProfileId || domainConfigParser?.getAttString('adminUserProfileId');
    if (!adminUserProfileId)
      throw new Error('adminUserProfileId must either be defined directly in props, or via domainConfigSSMParam');
    this.adminUserProfileId = adminUserProfileId;

    const projectProps: CfnProjectProps = {
      domainIdentifier: domainId,
      name: props.naming.resourceName(props.name, 80),
      ...props,
    };
    this.project = new CfnProject(this, 'project', projectProps);

    const projectMembershipProps: CfnProjectMembershipProps = {
      designation: 'PROJECT_OWNER',
      domainIdentifier: this.project.domainIdentifier,
      member: {
        userIdentifier: this.adminUserProfileId,
      },
      projectIdentifier: this.project.attrId,
    };
    const membership = new CfnProjectMembership(this, 'project-memebership', projectMembershipProps);
    membership.applyRemovalPolicy(RemovalPolicy.RETAIN);

    new MdaaParamAndOutput(
      this,
      {
        ...{
          resourceType: 'project',
          resourceId: props.name,
          name: 'name',
          value: this.project.name,
        },
        ...props,
      },
      scope,
    );
  }