With c7n-org I am attempting to run this policy wh...
# general
b
With c7n-org I am attempting to run this policy which is almost identical to what the doc example (https://cloudcustodian.io/docs/aws/resources/aws-common-filters.html#aws-common-filters-usage) provides:
Copy code
- 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:
Copy code
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?
k
Are you running multiple policies?
Can you pass the —debug flag it will run serially and give a full trace back
What’s your credential source in this context?
b
I am running this c7n-org command:
Copy code
c7n-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:
Copy code
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)
k
Seems like a permission error re access denied
b
Adding these three permissions fixed the problem:
Copy code
"iam:GetUser",
"iam:GenerateServiceLastAccessedDetails",
"iam:GetServiceLastAccessedDetails",
However, the initial error stating,
"argument of type 'type' is not iterable"
is deceiving.