duo-labs / duo-labs/cloudmapper
get_account_stats bucket_region = get_parameter_file( TypeError: 'NoneType' object is not subscriptable
- Dominant language
- JavaScript
- Stars
- 6.3k
- Forks
- 836
- PR merge metrics
- No merged PRs in 30d
Description
Please mention the following:
- What command was run? python cloudmapper.py report --account my_account
- Are you working out of a virtualenv environment, Docker, or something else? virtualenv, Linux
I did get a number of errors during collect: s3.get_bucket_*({'Bucket': 'bucket-name'}): An error occurred (AccessDenied) when calling the GetBucket* operation: Access Denied
```
$ python cloudmapper.py report --account my_account
* Getting resource counts
Traceback (most recent call last):
File "cloudmapper.py", line 72, in
main()
File "cloudmapper.py", line 66, in main
commands[command].run(arguments)
File "/home/john.milton/src/github.com/duo-labs/cloudmapper/commands/report.py", line 471, in run
report(accounts, config, args)
File "/home/john.milton/src/github.com/duo-labs/cloudmapper/commands/report.py", line 100, in report
account_stats[account["name"]] = get_account_stats(
File "/home/john.milton/src/github.com/duo-labs/cloudmapper/shared/common.py", line 278, in get_account_stats
bucket_region = get_parameter_file(
TypeError: 'NoneType' object is not subscriptable
```
wrapping a try/except around it got around this error:
```
diff --git a/shared/common.py b/shared/common.py
index e1a3708..5b711e6 100644
--- a/shared/common.py
+++ b/shared/common.py
@@ -275,10 +275,12 @@ def get_account_stats(account, all_resources=False):
)
for bucket in buckets:
# Get the bucket's location
- bucket_region = get_parameter_file(
- region, "s3", "get-bucket-location", bucket
- )["LocationConstraint"]
-
+ try:
+ bucket_region = get_parameter_file(
+ region, "s3", "get-bucket-location", bucket
+ )["LocationConstraint"]
+ except TypeError:
+ bucket_region=None
# Convert the value to a name.
# See https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
if bucket_region is None:
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.