Repository: cloud-custodian/cloud-custodian

Issue:
Event Pattern is not valid, PHD all events
**Describe the bug**

```
botocore.errorfactory.InvalidEventPatternException: An error occurred (InvalidEventPatternException) when calling the PutRule operation: Event pattern is not valid. Reason: Empty objects are not allowed at [Source: (String)"{"source": ["aws.health"], "detail": {}}"; line: 1, column: 40]
```

**To Reproduce**
Steps to reproduce the behavior:

Create a PHD alert for all events

**Expected behavior**
No Error


**Background (please complete the following information):**
  - Custodian Version: [e.g. 0.9.10.]
 
 - Policy: [please exclude any account/sensitive information]
```yaml
policies:
  - name: phd-alerts
    resource: account
    comment: PHD alerts
    mode:
      type: phd
      role: xxxxx
    description: Any PHD alert
```
**Additional context**
Add any other context about the problem here.

https://github.com/cloud-custodian/cloud-custodian/blob/master/c7n/mu.py#L1074

The empty object at the above line causes the boto3 error


Discussion:
kapilt: merging per discussion in #6638 

Patch:
diff --git a/c7n/mu.py b/c7n/mu.py
index c8d0dff9a..fb63dcd2f 100644
--- a/c7n/mu.py
+++ b/c7n/mu.py
@@ -1078,6 +1078,8 @@ class CloudWatchEventSource(AWSEventBase):
                 })
             if self.data.get('categories', []):
                 payload['detail']['eventTypeCategory'] = self.data['categories']
+            if not payload['detail']:
+                payload.pop('detail')
         elif event_type == 'hub-finding':
             payload['source'] = ['aws.securityhub']
             payload['detail-type'] = ['Security Hub Findings - Imported']


Test patch:
diff --git a/tests/test_mu.py b/tests/test_mu.py
index 14978e48c..3f9ec7013 100644
--- a/tests/test_mu.py
+++ b/tests/test_mu.py
@@ -208,6 +208,19 @@ class PolicyLambdaProvision(BaseTest):
         self.assertEqual(len(resources), 1)
         self.assertTrue('c7n:HealthEvent' in resources[0])
 
+    def test_phd_mode_sans_details(self):
+        factory = self.replay_flight_data('test_phd_event_mode')
+        p = self.load_policy(
+            {'name': 'ec2-retire',
+             'resource': 'account',
+             'mode': {'type': 'phd'}}, session_factory=factory)
+        p_lambda = PolicyLambda(p)
+        events = p_lambda.get_events(factory)
+        self.assertEqual(
+            json.loads(events[0].render_event_pattern()),
+            {'source': ['aws.health']}
+        )
+
     def test_phd_mode(self):
         factory = self.replay_flight_data('test_phd_event_mode')
         p = self.load_policy(