private getInitializeOrganizationalUnitsActions()

in source/repositories/compliant-framework-central-pipeline/lib/environment-pipeline-stack.ts [257:313]


  private getInitializeOrganizationalUnitsActions(): codepipeline.IAction[] {

    let actions: codepipeline.IAction[] = []

    for (const region of this.props.config.deployToRegions) {
      let coreAccounts: string[] = []

      // Transit Account
      if (region in this.props.config.transit) {
        let transitAccountId =
          this.props.config.transit[region]
            .environments[this.props.environment].accountId
        coreAccounts.push(transitAccountId)
      }

      // Management Services
      if (region in this.props.config.managementServices) {
        let managementServicesAccountId =
          this.props.config.managementServices[region]
            .environments[this.props.environment].accountId
        coreAccounts.push(managementServicesAccountId)
      }

      let tenantAccounts: string[] = []

      // All the Plugins
      for (var plugin in this.props.config.plugins) {
        if (region in this.props.config.plugins[plugin]) {
          for (var action of this.props.config.plugins[plugin][region].actions) {
            var accountId = action.environments[this.props.environment].accountId

            // Add the account to the list only if it's not a core account
            if (!tenantAccounts.includes(accountId) &&
              !coreAccounts.includes(accountId) &&
              accountId != this.props.config.central.accountId &&
              accountId != this.props.config.logging.accountId) {
              tenantAccounts.push(accountId)
            }
          }
        }
      }

      actions.push(
        new codepipeline_actions.LambdaInvokeAction({
          actionName: `initializeOrgUnits-${cfw.getActionName(region)}`,
          lambda: this.lambdas['initialize_organizational_units'],
          userParameters: {
            'ouName': this.getOuName(region),
            'coreAccounts': coreAccounts,
            'tenantAccounts': tenantAccounts
          },
          runOrder: 1,
        }),
      )
    }
    return actions
  }