예제 #1
0
def test_format_responses():
    org_id, root_id = build_mock_org(SIMPLE_ORG_SPEC)
    crawler = setup_crawler(ORG_ACCESS_ROLE)
    crawler.execute(payloads.get_account_aliases)
    execution = crawler.execute(payloads.get_account_aliases)
    execution_responses = format_responses(execution)
    print(yamlfmt(execution_responses))
    assert isinstance(execution_responses, list)
    for response in execution_responses:
        assert 'Account' in response
        assert 'Regions' in response
예제 #2
0
def test_format_responses():
    MockOrganization().simple()
    crawler = setup_crawler(ORG_ACCESS_ROLE)
    crawler.execute(payload.get_mock_account_alias)
    execution = crawler.execute(payload.get_mock_account_alias)
    execution_responses = format_responses(execution)
    print(yamlfmt(execution_responses))
    assert isinstance(execution_responses, list)
    for response in execution_responses:
        assert 'Account' in response
        assert 'Regions' in response
예제 #3
0
def main(master_role, account_role, regions, accounts,
        service, payload_file, payload, payload_arg):
    """
Arguments:

    \b
    PAYLOAD       Name of the payload function to run in each account
    PAYLOAD_ARG   The payload function argument(s) if any

Orgcrawler attempts to resolve payload function name from $PYTHON_PATH

Examples:

    \b
    orgcrawler -h
    orgcrawler -r OrgMasterRole orgcrawler.payloads.list_buckets
    orgcrawler -r OrgMasterRole --account-role S3Admin orgcrawler.payloads.list_buckets
    orgcrawler -r OrgMasterRole --service codecommit -f ~/my_payloads.py list_cc_repositories
    orgcrawler -r OrgMasterRole --service iam orgcrawler.payloads.get_account_aliases
    orgcrawler -r OrgMasterRole --accounts app-test,app-prod \\
            --regions us-east-1,us-west-2 orgcrawler.payloads.config_describe_rules
    """
    crawler_args = dict()
    if accounts:
        crawler_args['accounts'] = accounts.split(',')
    if service:
        crawler_args['regions'] = regions_for_service(service)
    elif regions:
        crawler_args['regions'] = regions.split(',')
    if account_role:
        crawler_args['account_access_role'] = account_role
    if payload_file:
        payload = get_payload_function_from_file(payload_file, payload)
    else:
        payload = get_payload_function_from_string(payload)

    crawler = setup_crawler(master_role, **crawler_args)
    execution = crawler.execute(payload, *payload_arg)
    click.echo(jsonfmt(format_responses(execution)))
예제 #4
0
def main(master_role, account_role, regions, accounts, service, payload_file,
         payload, payload_arg):
    ''' Where 'PAYLOAD' is name of the payload function to run in each account,
    and 'PAYLOAD_ARG' is, you guessed it, any payload function argument(s).
    Orgcrawler attempts to resolve payload function name from $PYTHON_PATH '''

    crawler_args = dict()
    if accounts:
        crawler_args['accounts'] = accounts.split(',')
    if service:
        crawler_args['regions'] = regions_for_service(service)
    elif regions:
        crawler_args['regions'] = regions.split(',')
    if account_role:
        crawler_args['account_access_role'] = account_role
    if payload_file:
        payload = get_payload_function_from_file(payload_file, payload)
    else:
        payload = get_payload_function_from_string(payload)

    crawler = setup_crawler(master_role, **crawler_args)
    execution = crawler.execute(payload, *payload_arg)
    click.echo(jsonfmt(format_responses(execution)))