Repository: cloud-custodian/cloud-custodian

Issue:
Error while running report command for vpc-endpoint resource
### Error while running report command for vpc-endpoint resource

#### Policy 

> policies:
> 
>   - name: vpc-endpoint
>     resource: vpc-endpoint

```
Traceback (most recent call last):
  File "/usr/local/bin/c7n-org", line 9, in <module>
    load_entry_point('c7n-org==0.2.2', 'console_scripts', 'c7n-org')()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/c7n_org/cli.py", line 242, in report
    fields=prefix_fields)
  File "/usr/local/lib/python2.7/dist-packages/c7n/reports/csvout.py", line 158, in __init__
    if model.name != model.id:
AttributeError: type object 'resource_type' has no attribute 'name'```


Discussion:
noted, thanks for the bug report.

Resolving patch:
diff --git a/c7n/resources/cw.py b/c7n/resources/cw.py
--- a/c7n/resources/cw.py
+++ b/c7n/resources/cw.py
@@ -99,6 +99,7 @@ class resource_type(object):
         type = 'event-rule-target'
         enum_spec = ('list_targets_by_rule', 'Targets', None)
         parent_spec = ('event-rule', 'Rule', True)
+        name = id = 'Id'
         dimension = None
         filter_type = filter_name = None
 
diff --git a/c7n/resources/shield.py b/c7n/resources/shield.py
--- a/c7n/resources/shield.py
+++ b/c7n/resources/shield.py
@@ -40,7 +40,7 @@ class resource_type(object):
         service = 'shield'
         enum_spec = ('list_attacks', 'Attacks', None)
         detail_spec = ('describe_attack', 'AttackId', 'AttackId', 'Attack')
-        id = 'AttackId'
+        name = id = 'AttackId'
         date = 'StartTime'
         dimension = None
         filter_name = 'ResourceArns'
diff --git a/c7n/resources/vpc.py b/c7n/resources/vpc.py
--- a/c7n/resources/vpc.py
+++ b/c7n/resources/vpc.py
@@ -1539,7 +1539,7 @@ class resource_type(object):
         service = 'ec2'
         type = 'vpc-endpoint'
         enum_spec = ('describe_vpc_endpoints', 'VpcEndpoints', None)
-        id = 'VpcEndpointId'
+        name = id = 'VpcEndpointId'
         date = 'CreationTimestamp'
         filter_name = 'VpcEndpointIds'
         filter_type = 'list'


Test patch:
diff --git a/tests/test_policy.py b/tests/test_policy.py
--- a/tests/test_policy.py
+++ b/tests/test_policy.py
@@ -141,6 +141,16 @@ def test_resource_shadow_source_augment(self):
                 "%s have config types but no config source" % (
                     ", ".join(bad)))
 
+    def test_resource_name(self):
+        names = []
+        for k, v in manager.resources.items():
+            if not getattr(v.resource_type, 'name', None):
+                names.append(k)
+        if names:
+            self.fail(
+                '%s dont have resource name for reporting' % (
+                    ", ".join(names)))
+
     def test_resource_permissions(self):
         self.capture_logging('c7n.cache')
         missing = []