Repository: cloud-custodian/cloud-custodian

Issue:
Credential report failing 
Hi, I just rolled out the latest cloud custodian to my env. Some iam account policy stuff appears to be breaking because of a change. It appears that this error initially appeared in pr #1343 

Stack trace
```
2017-07-20 13:33:21,212: custodian.output:ERROR Error while executing policy
Traceback (most recent call last):
  File "/Users/jtrenholm/work/github-cloud-custodian/cloud-custodian-orig/c7n/policy.py", line 305, in run
    resources = self.policy.resource_manager.resources()
  File "/Users/jtrenholm/work/github-cloud-custodian/cloud-custodian-orig/c7n/query.py", line 294, in resources
    return self.filter_resources(resources)
  File "/Users/jtrenholm/work/github-cloud-custodian/cloud-custodian-orig/c7n/manager.py", line 88, in filter_resources
    resources = f.process(resources, event)
  File "/Users/jtrenholm/work/github-cloud-custodian/cloud-custodian-orig/c7n/resources/iam.py", line 645, in process
    report = self.get_credential_report()
  File "/Users/jtrenholm/work/github-cloud-custodian/cloud-custodian-orig/c7n/resources/iam.py", line 564, in get_credential_report
    reader = csv.reader(io.StringIO(data))
TypeError: initial_value must be unicode or None, not str
2017-07-20 13:33:21,212: custodian.commands:ERROR Error while executing policy iam_accounts-notify-remove-never_used, continuing
```
Policy
```
policies:
  - name: iam_accounts-notify-remove-never_used
    description: |
       Notification for 5 days or less before removing IAM accounts that have never been used
    resource: iam-user
    filters:
      - type: credential
        key: user
        value: *whitelisted_users
        op: not-in
      - type: credential
        key: access_keys.last_used_date
        value: absent
      - type: credential
        key: access_keys.last_rotated
        value_type: age
        value: 85
        op: gte
```


Discussion:
ugh.. py3 support definitely has caused some issues ( @whit537 ). thanks for the report.

Resolving patch:
diff --git a/c7n/resources/iam.py b/c7n/resources/iam.py
--- a/c7n/resources/iam.py
+++ b/c7n/resources/iam.py
@@ -561,7 +561,10 @@ def get_credential_report(self):
             return report
         data = self.fetch_credential_report()
         report = {}
-        reader = csv.reader(io.StringIO(data))
+        if isinstance(data, six.binary_type):
+            reader = csv.reader(io.BytesIO(data))
+        else:
+            reader = csv.reader(io.StringIO(data))
         headers = next(reader)
         for line in reader:
             info = dict(zip(headers, line))
diff --git a/c7n/version.py b/c7n/version.py
--- a/c7n/version.py
+++ b/c7n/version.py
@@ -12,4 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-version = u"0.8.24.4"
+version = u"0.8.24.5"
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ def read(fname):
 
 setup(
     name="c7n",
-    version='0.8.24.4',
+    version='0.8.24.5',
     description="Cloud Custodian - Policy Rules Engine",
     long_description=read('README.rst'),
     classifiers=[


Test patch: