manheim / manheim-c7n-tools

Manheim's Cloud Custodian (c7n) wrapper package, policy generator, runner, and supporting tools.
https://manheim-c7n-tools.readthedocs.io/
Apache License 2.0
45 stars 25 forks source link

Failed to run without the us-east-1 region #24

Closed robertstettner closed 4 years ago

robertstettner commented 4 years ago

The tool complains that the us-east-1 region is required. Furthermore, after adding it in the config, if there are no account-wide, or org-wide policies, and only certain region policies, barring the us-east-1, because say, we don't use that region, what shall we do?

The error for when the tool tries to run no policies for a region is below:

[2020-04-02 11:26:38,422 INFO] Step custodian in REGION 1 of 4 (us-east-1)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/c7n/config.py", line 25, in __getattr__
    return self[k]
KeyError: 'policy_filters'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/manheim-c7n-runner", line 11, in <module>
    load_entry_point('manheim-c7n-tools', 'console_scripts', 'manheim-c7n-runner')()
  File "/manheim_c7n_tools/manheim_c7n_tools/runner.py", line 622, in main
    args.ACTION, args.regions, step_names=args.steps, skip_steps=args.skip
  File "/manheim_c7n_tools/manheim_c7n_tools/runner.py", line 484, in run
    self._run_step_in_regions(action, step, regions)
  File "/manheim_c7n_tools/manheim_c7n_tools/runner.py", line 539, in _run_step_in_regions
    step(region_name, region_conf).dryrun()
  File "/manheim_c7n_tools/manheim_c7n_tools/runner.py", line 267, in dryrun
    run(conf)
  File "/usr/local/lib/python3.7/site-packages/c7n/commands.py", line 117, in _load_policies
    _print_no_policies_warning(options, all_policies)
  File "/usr/local/lib/python3.7/site-packages/c7n/commands.py", line 161, in _print_no_policies_warning
    if options.policy_filters or options.resource_types:
  File "/usr/local/lib/python3.7/site-packages/c7n/config.py", line 27, in __getattr__
    raise AttributeError(k)
AttributeError: policy_filters

The error for the tool complaining it needs the us-east-1 region is:

[2020-04-02 09:22:44,711 INFO] Loading config from: manheim-c7n-tools.yml
Traceback (most recent call last):
  File "/usr/local/bin/manheim-c7n-runner", line 11, in <module>
    load_entry_point('manheim-c7n-tools', 'console_scripts', 'manheim-c7n-runner')()
  File "/manheim_c7n_tools/manheim_c7n_tools/runner.py", line 618, in main
    cr = CustodianRunner(args.ACCT_NAME, args.config)
  File "/manheim_c7n_tools/manheim_c7n_tools/runner.py", line 413, in __init__
    self.config = ManheimConfig.from_file(config_path, account_name)
  File "/manheim_c7n_tools/manheim_c7n_tools/config.py", line 146, in from_file
    return ManheimConfig(**acct_conf)
  File "/manheim_c7n_tools/manheim_c7n_tools/config.py", line 122, in __init__
    'ERROR: the first configured region must be us-east-1'
RuntimeError: ERROR: the first configured region must be us-east-1
jantman commented 4 years ago

Hmm... so I don't doubt that this is true, and a valid bug. However it's also likely never going to impact us here at Manheim, for various reasons (including that we run c7n in a minimum set of regions in every account, regardless of whether the regions are actually "in use" in that account or not).

I can't make any promises about when this will get fixed. I'll do my best to address it next time I do some major work on this project. Aside from that, pull requests are always welcome.

jantman commented 4 years ago

This has been released in 0.8.5, which should be published shortly. Thanks so much for reporting it!