How to use the cloudaux.orchestration.aws.arn.ARN function in cloudaux

To help you get started, we’ve selected a few cloudaux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Netflix-Skunkworks / cloudaux / cloudaux / orchestration / aws / elbv2.py View on Github external
"""
    Fully describes an ALB (ELBv2).

    :param alb: Could be an ALB Name, ALB ARN, or a dictionary. Likely the return value from a previous call to describe_load_balancers. At a minimum, must contain a key titled 'LoadBalancerArn'.
    :param flags: Flags describing which sections should be included in the return value. Default is FLAGS.ALL.
    :return: Returns a dictionary describing the ALB with the fields described in the flags parameter.
    """
    # Python 2 and 3 support:
    try:
        basestring
    except NameError as _:
        basestring = str

    if isinstance(alb, basestring):
        from cloudaux.orchestration.aws.arn import ARN
        alb_arn = ARN(alb)
        if alb_arn.error:
            alb = dict(LoadBalancerName=alb)
        else:
            alb = dict(LoadBalancerArn=alb)

    return registry.build_out(flags, start_with=alb, pass_datastructure=True, **conn)
github Netflix-Skunkworks / cloudaux / cloudaux / orchestration / aws / __init__.py View on Github external
def _conn_from_arn(arn):
    """
    Extracts the account number from an ARN.
    :param arn: Amazon ARN containing account number.
    :return: dictionary with a single account_number key that can be merged with an existing
    connection dictionary containing fields such as assume_role, session_name, region.
    """
    arn = ARN(arn)
    if arn.error:
        raise CloudAuxException('Bad ARN: {arn}'.format(arn=arn))
    return dict(
        account_number=arn.account_number,
    )
github Netflix-Skunkworks / cloudaux / cloudaux / orchestration / aws / glacier.py View on Github external
"CreationDate" ...,
        "LastInventoryDate" ...,
        "NumberOfArchives" ...,
        "SizeInBytes" ...,
        "Policy" ...,
        "Tags" ...
    }
    Args:
        vault_obj: name, ARN, or dict of Glacier Vault
        flags: Flags describing which sections should be included in the return value. Default ALL

    Returns:
        dictionary describing the requested Vault
    """
    if isinstance(vault_obj, string_types):
        vault_arn = ARN(vault_obj)
        if vault_arn.error:
            vault_obj = {'VaultName': vault_obj}
        else:
            vault_obj = {'VaultName': vault_arn.parsed_name}

    return registry.build_out(flags, vault_obj, **conn)
github Netflix-Skunkworks / cloudaux / cloudaux / orchestration / aws / __init__.py View on Github external
def _get_name_from_structure(item, default):
    """
    Given a possibly sparsely populated item dictionary, try to retrieve the item name.
    First try the default field.  If that doesn't exist, try to parse the from the ARN.
    :param item: dict containing (at the very least) item_name and/or arn
    :return: item name
    """
    if item.get(default):
        return item.get(default)

    if item.get('Arn'):
        arn = item.get('Arn')
        item_arn = ARN(arn)
        if item_arn.error:
            raise CloudAuxException('Bad ARN: {arn}'.format(arn=arn))
        return item_arn.parsed_name

    raise MissingFieldException('Cannot extract item name from input: {input}.'.format(input=item))
github Netflix / security_monkey / security_monkey / datastore_utils.py View on Github external
def create_item_aws(item, technology, account):
    arn = ARN(item.config.get('Arn'))
    return Item(
        region=arn.region or 'universal',
        name=arn.parsed_name or arn.name,
        arn=item.config.get('Arn'),
        tech_id=technology.id,
        account_id=account.id
    )