Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ProcessableAccount

The implementation of the ProcessableAccount Interface

Hierarchy

Index

Constructors

constructor

  • Creates a new instance of AwsOrgNode

    remarks

    The constructor is basically empty because we need to call async functions when we initialise the object and therefore we declare the static async function init() which is used in place of the constructor

    Returns ProcessableAccount

    A placeholder AwsOrgNode object

Properties

Optional Arn

Arn: string

Amazon Resource Name (ARN) of this node

Children

Children: AwsOrgNode[]

Array of Child AwsOrgNode Objects that are direct descendants

defaultvalue

[]

Id

Id: string

ID of the Node: [ 'Root', 'r-0abc', 'ou-0abc-abcdefgh', '123456789012' ]

remarks

This is the ID of an AWS Organizations object, but as an Organization may only have one root, it is not critical to initialise a ROOT AwsOrgNode with its Id; it's not worth doing a listRoots call just to find it at construction-time; therefore we permit the special value 'Root' which is also the default

defaultvalue

Root

Optional Name

Name: string

Name of this node

Organization

Organization: undefined | Organization

The result of Organizations.describeOrganization, when this is a ROOT node

RoleToAssume

RoleToAssume: AssumeRoleConfig

An AssumeRoleConfig object to be used by the AWS STS AssumeRole call in processAccount to get the role credentials to be passed into the callback

Optional Type

Type: string

Type of this node

remarks

This property is not normally used in our objects, but can be merged in from an Organizations.listChildren response, and therefore need to be an optional property

nodetype

nodetype: string

Type of AWS Organizations node: [ 'ROOT', 'ORGANIZATIONAL_UNIT', 'ACCOUNT' ]

defaultvalue

ROOT

Methods

AsyncCallback

  • An async callback function that takes credentials credentials and a ProcessableAccount and performs an operation in the account, to return the output of the operation

    Parameters

    Returns Promise<any>

addChild

getAccount

  • getAccount(Id: string, recursive?: boolean): undefined | AwsOrgNode
  • Get an ACCOUNT AwsOrgNode Object that is a child of this AwsOrgNode, or optionally of any descendants as well

    Parameters

    • Id: string

      The ID of an ACCOUNT AwsOrgNode to search for in the tree below this node

    • Optional recursive: boolean

      If true, search the whole tree. If false, only search immediate child accounts of this node

    Returns undefined | AwsOrgNode

    An AwsOrgNode object if one is found, or undefined if not

getAccounts

  • getAccounts(recursive?: boolean): AwsOrgNode[]
  • Get an Array of all ACCOUNT AwsOrgNode Objects that are children of this AwsOrgNode, or optionally of any descendants as well

    Parameters

    • Optional recursive: boolean

      If true, get all accounts in the tree below this nose, if false only get immediate child accounts of this node

    Returns AwsOrgNode[]

    An Array of ACCOUNT AwsOrgNode objects

getChild

  • getChild(Id: string): undefined | AwsOrgNode
  • Get an AwsOrgNode Object that is a direct child of this AwsOrgNode by it's Id property

    Parameters

    • Id: string

      The Id of the Child node to find

    Returns undefined | AwsOrgNode

    The AwsOrgNode Object with the provided Id, or undefined if it doesn't exist

getParentOusFor

  • getParentOusFor(Id: string): AwsOrgNode[]
  • Get an Array of AwsOrgNode Objects that are ancestors of the AwsOrgNode, identified by it's Id property, within the tree below this AwsOrgNode - except any that are ROOT nodes.

    remarks

    Identical to getParentsFor, but omit the ROOT, returning only ORGANIZATIONAL_UNITs.

    Parameters

    • Id: string

      The Id of the AwsOrgNode to get the Parents OUs for

    Returns AwsOrgNode[]

    An Array of ORGANIZATIONAL_UNIT AwsOrgNode objects that are antecedent to the object with the Id provided

getParentsFor

  • getParentsFor(Id: string): AwsOrgNode[]
  • Get an Array of AwsOrgNode Objects that are ancestors of the AwsOrgNode within the tree below this AwsOrgNode

    privateremarks

    This could probably be made safer by returning an optional undefined, but for the moment it presumes you wouldn't search for an Object ID that doesn't exist

    Parameters

    • Id: string

      The Id of the AwsOrgNode to get the Parents for

    Returns AwsOrgNode[]

    An Array of AwsOrgNode objects that are antecedent to the object with the Id provided

isAccount

  • isAccount(): boolean

isOrganizationalUnit

  • isOrganizationalUnit(): boolean

isRoot

  • isRoot(): boolean

toString

  • toString(): string

toTree

  • toTree(level?: number): string
  • A string representation of the tree of AwsOrgNodes beneath this one

    Parameters

    • Optional level: number

      A private recursion-control parameter

    Returns string

    A string representation of the AwsOrgNode tree

Static init

  • init(orgNode?: AwsOrgNode, skipSuspended?: boolean, orgAccounts?: AwsOrgNode[], orgParamOverrides?: Record<string, unknown>): Promise<AwsOrgNode>
  • Creates an initialised instance of an AwsOrgNode

    remarks

    This is the real constructor, that calls async functions to populate the Object with the data that makes this object useful By default we are an inferred Organization Root (as opposed to an explicit one defined by an ID like /r-[0-9a-z]{4}/)

    Properties in this class are capitalised based on whether they match data returned from the AWS APIs, or close-enough. nodetype is a concept custom to this class, and therefore lowercase. Arn and Name are returned from the AWS APIs and are therefore TitleCase. This allows us to use Object.assign to merge API results as if they were native object properties.

    example
    const { AwsOrgNode } = require('orgtomate');
    const awsOrg = await AwsOrgNode.init();
    console.log(awsOrg.toTree());
    
    example
    e=async()=>{const {AwsOrgNode}=require('.');console.log((await AwsOrgNode.init(new (require('aws-sdk').Organizations)({region:'us-east-1',maxRetries:100}))).toTree());};e();
    

    Parameters

    • orgNode: AwsOrgNode = ...

      An AwsOrgNode object to initialise. Optional. Defaults to an empty Root node

    • skipSuspended: boolean = false

      Whether to include AWS Accounts in a SUSPENDED state. Optional. Defaults to false

    • orgAccounts: AwsOrgNode[] = []

      The output from org.listAccounts(). Optional. Performed once per tree initialisation, all children are passed the list generated in the parent's initialisation.

    • orgParamOverrides: Record<string, unknown> = {}

    Returns Promise<AwsOrgNode>

    A Promise to return the fully initialised AwsOrgNode Object, with all populated Children

Generated using TypeDoc