async getPlanBasedUserPool()

in services/shared/apps/tenant-registration/src/idp-service/idp.service.ts [29:67]


  async getPlanBasedUserPool(tenantId: string, path: string, plan: PLAN_TYPE) {
    // Our pool type is based solely on Plan
    const poolType =
      plan === PLAN_TYPE.Premium ? USERPOOL_TYPE.Siloed : USERPOOL_TYPE.Pooled;
    // Our incoming 'Path' parameter is a shortened version of the company name
    // It's only used in the case this tenant is siloed.
    // All non-premium tenants will use the pooled compute which runs at http://abc.com/app
    // Premium tenants will run at http://abc.com/{pathToUse}
    const pathToUse = plan === PLAN_TYPE.Premium ? path : 'app';
    console.log('Fetching pool for this path:', pathToUse);
    // See if we have an existing entry based on the path.
    const existingPoolId = await this.fetchForPath(pathToUse);
    console.log('existingPoolId:', existingPoolId);
    if (!!existingPoolId) {
      return existingPoolId;
    }

    console.log('Existing pool not found. Creating new siloed pool');
    // If we get here, we're only interested in creating a siloed
    // tenant's user pool
    const poolName = `eks-ws-siloed-${tenantId}`;
    const userPool = await this.createUserPool(poolName, pathToUse);
    const userPoolClient = await this.createUserPoolClient(
      tenantId,
      userPool.Id,
    );
    await this.storeForPath(
      pathToUse,
      poolType,
      userPool.Id,
      userPoolClient.ClientId,
    );
    await this.storeTenantStackMappingData(
      path,
      userPool.Id,
      userPoolClient.ClientId,
    );
    return userPool.Id;
  }