Brian Gaber
07/31/2025, 9:25 PM- name: unused-credentials
resource: iam-user
filters:
- type: usage
LastAuthenticated:
type: value
value_type: age
op: greater-than
value: 45
match-operator: any
I get this error:
c7n_org:ERROR Exception running policy:unused-credentials account:go-noc-rd region:us-east-1 error:argument of type 'type' is not iterable
Any ideas on cause of error?kapilt
07/31/2025, 9:36 PMkapilt
07/31/2025, 9:36 PMkapilt
07/31/2025, 9:36 PMBrian Gaber
08/01/2025, 1:48 AMc7n-org run -c accounts.yml -s /tmp -u ~/fedramp-cloud-custodian/iam-unused.yml --dryrun --debug
where iam-unused.yml contains just one policy named unused-credentials.
The credential source is AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
Here is full trace output from the --debug flag:
2025-07-31 21:42:20,167: c7n_org:ERROR Exception running policy:iam-unused-credentials-45-days account:go-noc-rd region:us-east-1 error:argument of type 'type' is not iterable
Traceback (most recent call last):
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/utils.py", line 457, in _retry
return func(*args, **kw)
^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/botocore/client.py", line 601, in _api_call
return self._make_api_call(operation_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/botocore/context.py", line 123, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/botocore/client.py", line 1074, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the GetUser operation: User: arn:aws:sts::805960120419:assumed-role/cloud-custodian-role-assumed/CloudCustodian is not authorized to perform: iam:GetUser on resource: user AnsibleAuto because no identity-based policy allows the iam:GetUser action
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n_org/cli.py", line 662, in run_account
resources = p.run()
^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/policy.py", line 1382, in __call__
resources = PullMode(self).run()
^^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/policy.py", line 330, in run
resources = self.policy.resource_manager.resources()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/query.py", line 543, in resources
resources = self.augment(resources)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/query.py", line 599, in augment
return self.source.augment(resources)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/resources/iam.py", line 228, in augment
ru = self.manager.retry(
^^^^^^^^^^^^^^^^^^^
File "/home/briang/c7n-org/lib/python3.12/site-packages/c7n/utils.py", line 459, in _retry
if e.response['Error']['Code'] in ignore_err_codes:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'type' is not iterable
> /home/briang/c7n-org/lib/python3.12/site-packages/c7n/utils.py(459)_retry()
-> if e.response['Error']['Code'] in ignore_err_codes:
(Pdb)kapilt
08/01/2025, 2:00 AMBrian Gaber
08/01/2025, 2:11 AM"iam:GetUser",
"iam:GenerateServiceLastAccessedDetails",
"iam:GetServiceLastAccessedDetails",
However, the initial error stating, "argument of type 'type' is not iterable" is deceiving.