lib/plugins/aws/package/compile/events/cognitoUserPool/index.js/AwsCompileCognitoUserPoolEvents/mergeWithCustomResources
class AwsCompileCognitoUserPoolEvents:  mergeWithCustomResources() {
    const result = this.findUserPoolsAndFunctions();
    const cognitoUserPoolTriggerFunctions = result.cognitoUserPoolTriggerFunctions;
    const userPools = result.userPools;

    _.forEach(userPools, (poolName) => {
      const currentPoolTriggerFunctions = _.filter(cognitoUserPoolTriggerFunctions, { poolName });
      const userPoolLogicalId = this.provider.naming.getCognitoUserPoolLogicalId(poolName);

      // If overrides exist in `Resources`, merge them in
      if (_.has(this.serverless.service.resources, userPoolLogicalId)) {
        const customUserPool = this.serverless.service.resources[userPoolLogicalId];
        const generatedUserPool = this.generateTemplateForPool(
          poolName,
          currentPoolTriggerFunctions
        )[userPoolLogicalId];

        // Merge `DependsOn` clauses
        const customUserPoolDependsOn = _.get(customUserPool, 'DependsOn', []);
        const DependsOn = generatedUserPool.DependsOn.concat(customUserPoolDependsOn);

        // Merge default and custom resources, and `DependsOn` clause
        const mergedTemplate = Object.assign(
          {},
          _.merge(generatedUserPool, customUserPool),
          { DependsOn }
        );

        // Merge resource back into `Resources`
        _.merge(
          this.serverless.service.provider.compiledCloudFormationTemplate.Resources,
          { [userPoolLogicalId]: mergedTemplate }
        );
      }
    });
  }