Repository: cloud-custodian/cloud-custodian

Issue:
aws - correct default cloudwatch metric namespace for emr
The Default namespace for EMR Cloudwatch metrics is incorrect in filters/metrics.py

```
# ditto for spot fleet DEFAULT_NAMESPACE = { 'cloudfront': 'AWS/CloudFront', 'cloudsearch': 'AWS/CloudSearch', 'dynamodb': 'AWS/DynamoDB', 'ecs': 'AWS/ECS', 'elasticache': 'AWS/ElastiCache', 'ec2': 'AWS/EC2', 'elb': 'AWS/ELB', 'elbv2': 'AWS/ApplicationELB', 'emr': 'AWS/EMR', 'es': 'AWS/ES', 'events': 'AWS/Events', 'firehose': 'AWS/Firehose', 'kinesis': 'AWS/Kinesis', 'lambda': 'AWS/Lambda', 'logs': 'AWS/Logs', 'redshift': 'AWS/Redshift', 'rds': 'AWS/RDS', 'route53': 'AWS/Route53', 's3': 'AWS/S3', 'sns': 'AWS/SNS', 'sqs': 'AWS/SQS', }

```
emr should be mapped to 'AWS/ElasticMapReduce' rather than 'AWS/EMR'

See
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html


Discussion:
Thanks for the pull request!  looks good to me, looks like a travis hiccup on the ci..  If you don't mind could you sign the CLA at the bottom of the README? Direct link here: https://docs.google.com/forms/d/e/1FAIpQLSfwtl1s6KmpLhCY6CjiY8nFZshDwf_wrmNYx1ahpsNFXXmHKw/viewform
Yes sure. I've signed the CLA.

Resolving patch:
diff --git a/c7n/resources/ssm.py b/c7n/resources/ssm.py
--- a/c7n/resources/ssm.py
+++ b/c7n/resources/ssm.py
@@ -14,11 +14,15 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 
 
+from c7n.exceptions import PolicyValidationError
 from c7n.query import QueryResourceManager
 from c7n.manager import resources
-from c7n.utils import get_retry, local_session, type_schema
+from c7n.utils import chunks, get_retry, local_session, type_schema
 from c7n.actions import Action
 
+from .aws import shape_validate
+from .ec2 import EC2
+
 
 @resources.register('ssm-parameter')
 class SSMParameter(QueryResourceManager):
@@ -49,6 +53,80 @@ class resource_type(object):
     permissions = ('ssm:DescribeInstanceInformation',)
 
 
+@EC2.action_registry.register('send-command')
+@ManagedInstance.action_registry.register('send-command')
+class SendCommand(Action):
+    """Run an SSM Automation Document on an instance.
+
+    :Example:
+
+    Find ubuntu 18.04 instances are active with ssm.
+
+    .. code-block:: yaml
+
+        policies:
+          - name: ec2-osquery-install
+            resource: ec2
+            filters:
+              - type: ssm
+                key: PingStatus
+                value: Online
+              - type: ssm
+                key: PlatformName
+                value: Ubuntu
+              - type: ssm
+                key: PlatformVersion
+                value: 18.04
+            actions:
+              - type: send-command
+                command:
+                  DocumentName: AWS-RunShellScript
+                  Parameters:
+                    commands:
+                      - wget https://pkg.osquery.io/deb/osquery_3.3.0_1.linux.amd64.deb
+                      - dpkg -i osquery_3.3.0_1.linux.amd64.deb
+    """
+
+    schema = type_schema(
+        'send-command',
+        command={'type': 'object'},
+        required=('command',))
+
+    permissions = ('ssm:SendCommand',)
+    shape = "SendCommandRequest"
+    annotation = 'c7n:SendCommand'
+
+    def validate(self):
+        shape_validate(self.data['command'], self.shape, 'ssm')
+        # If used against an ec2 resource, require an ssm status filter
+        # to ensure that we're not trying to send commands to instances
+        # that aren't in ssm.
+        if self.manager.type != 'ec2':
+            return
+
+        found = False
+        for f in self.manager.iter_filters():
+            if f.type == 'ssm':
+                found = True
+                break
+        if not found:
+            raise PolicyValidationError(
+                "send-command requires use of ssm filter on ec2 resources")
+
+    def process(self, resources):
+        client = local_session(self.manager.session_factory).client('ssm')
+        for resource_set in chunks(resources, 50):
+            self.process_resource_set(client, resource_set)
+
+    def process_resource_set(self, client, resources):
+        command = dict(self.data['command'])
+        command['InstanceIds'] = [
+            r['InstanceId'] for r in resources]
+        result = client.send_command(**command).get('Command')
+        for r in resources:
+            r.setdefault('c7n:SendCommand', []).append(result['CommandId'])
+
+
 @resources.register('ssm-activation')
 class SSMActivation(QueryResourceManager):
     class resource_type(object):


Test patch:
diff --git a/tests/data/placebo/test_ssm_send_command/ssm.DescribeInstanceInformation_1.json b/tests/data/placebo/test_ssm_send_command/ssm.DescribeInstanceInformation_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_ssm_send_command/ssm.DescribeInstanceInformation_1.json
@@ -0,0 +1,66 @@
+{
+    "status_code": 200,
+    "data": {
+        "InstanceInformationList": [
+            {
+                "InstanceId": "i-0ba3874e85bb97244",
+                "PingStatus": "Online",
+                "LastPingDateTime": {
+                    "__class__": "datetime",
+                    "year": 2019,
+                    "month": 1,
+                    "day": 30,
+                    "hour": 9,
+                    "minute": 15,
+                    "second": 7,
+                    "microsecond": 712000
+                },
+                "AgentVersion": "2.3.274.0",
+                "IsLatestVersion": false,
+                "PlatformType": "Linux",
+                "PlatformName": "Ubuntu",
+                "PlatformVersion": "18.04",
+                "ResourceType": "EC2Instance",
+                "IPAddress": "172.31.10.93",
+                "ComputerName": "ip-172-31-10-93",
+                "AssociationStatus": "Success",
+                "LastAssociationExecutionDate": {
+                    "__class__": "datetime",
+                    "year": 2019,
+                    "month": 1,
+                    "day": 30,
+                    "hour": 9,
+                    "minute": 12,
+                    "second": 3,
+                    "microsecond": 0
+                },
+                "LastSuccessfulAssociationExecutionDate": {
+                    "__class__": "datetime",
+                    "year": 2019,
+                    "month": 1,
+                    "day": 30,
+                    "hour": 9,
+                    "minute": 12,
+                    "second": 3,
+                    "microsecond": 0
+                },
+                "AssociationOverview": {
+                    "InstanceAssociationStatusAggregatedCount": {
+                        "Success": 1
+                    }
+                }
+            }
+        ],
+        "ResponseMetadata": {
+            "RequestId": "7d34aa11-8db8-45cb-a2ca-937b4479a8fa",
+            "HTTPStatusCode": 200,
+            "HTTPHeaders": {
+                "x-amzn-requestid": "7d34aa11-8db8-45cb-a2ca-937b4479a8fa",
+                "content-type": "application/x-amz-json-1.1",
+                "content-length": "548",
+                "date": "Wed, 30 Jan 2019 14:16:02 GMT"
+            },
+            "RetryAttempts": 0
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_ssm_send_command/ssm.GetCommandInvocation_1.json b/tests/data/placebo/test_ssm_send_command/ssm.GetCommandInvocation_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_ssm_send_command/ssm.GetCommandInvocation_1.json
@@ -0,0 +1,36 @@
+{
+    "status_code": 200,
+    "data": {
+        "CommandId": "139fedb0-4913-47da-bb53-c08364f07c22",
+        "InstanceId": "i-0ba3874e85bb97244",
+        "Comment": "",
+        "DocumentName": "AWS-RunShellScript",
+        "DocumentVersion": "",
+        "PluginName": "aws:runShellScript",
+        "ResponseCode": 0,
+        "ExecutionStartDateTime": "2019-01-30T14:16:03.478Z",
+        "ExecutionElapsedTime": "PT1.755S",
+        "ExecutionEndDateTime": "2019-01-30T14:16:04.478Z",
+        "Status": "Success",
+        "StatusDetails": "Success",
+        "StandardOutputContent": "Selecting previously unselected package osquery.\n(Reading database ... 56473 files and directories currently installed.)\nPreparing to unpack osquery_3.3.0_1.linux.amd64.deb ...\nUnpacking osquery (3.3.0-1.linux) ...\nSetting up osquery (3.3.0-1.linux) ...\n1037\nProcessing triggers for ureadahead (0.100.0-20) ...\nProcessing triggers for systemd (237-3ubuntu10.3) ...\n",
+        "StandardOutputUrl": "",
+        "StandardErrorContent": "--2019-01-30 14:16:03--  https://pkg.osquery.io/deb/osquery_3.3.0_1.linux.amd64.deb\nResolving pkg.osquery.io (pkg.osquery.io)... 54.193.126.242\nConnecting to pkg.osquery.io (pkg.osquery.io)|54.193.126.242|:443... connected.\nHTTP request sent, awaiting response... 301 Moved Permanently\nLocation: https://osquery-packages.s3.amazonaws.com/deb/osquery_3.3.0_1.linux.amd64.deb [following]\n--2019-01-30 14:16:03--  https://osquery-packages.s3.amazonaws.com/deb/osquery_3.3.0_1.linux.amd64.deb\nResolving osquery-packages.s3.amazonaws.com (osquery-packages.s3.amazonaws.com)... 52.216.128.171\nConnecting to osquery-packages.s3.amazonaws.com (osquery-packages.s3.amazonaws.com)|52.216.128.171|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 10304582 (9.8M) [application/vnd.debian.binary-package]\nSaving to: \u2018osquery_3.3.0_1.linux.amd64.deb\u2019\n\n     0K .......... .......... .......... .......... ..........  0% 3.92M 2s\n    50K .......... .......... .......... .......... ..........  0% 3.90M 2s\n   100K .......... .......... .......... .......... ..........  1% 4.13M 2s\n   150K .......... .......... .......... .......... ..........  1% 55.5M 2s\n   200K .......... .......... .......... .......... ..........  2% 55.5M 2s\n   250K .......... .......... .......... .......... ..........  2% 4.53M 2s\n   300K .......... .......... .......... .......... ..........  3% 45.4M 1s\n   350K .......... .......... .......... .......... ..........  3% 45.8M 1s\n   400K .......... .......... .......... .......... ..........  4% 57.2M 1s\n   450K .......... .......... .......... .......... ..........  4% 53.7M 1s\n   500K .......... .......... .......... .......... ..........  5% 6.30M 1s\n   550K .......... .......... .......... .......... ..........  5% 49.9M 1s\n   600K .......... .......... .......... .......... ..........  6% 53.4M 1s\n   650K .......... .......... .......... .......... ..........  6% 54.7M 1s\n   700K .......... .......... .......... .......... ..........  7% 57.1M 1s\n   750K .......... .......... .......... .......... ..........  7% 56.5M 1s\n   800K .......... .......... .......... .......... ..........  8% 49.8M 1s\n   850K .......... .......... .......... .......... ..........  8% 65.8M 1s\n   900K .......... .......... .......... .......... ..........  9% 56.4M 1s\n   950K .......... .......... .......... .......... ..........  9% 53.9M 1s\n  1000K .......... .......... .......... .......... .......... 10% 46.2M 1s\n  1050K .......... .......... .......... .......... .......... 10% 56.2M 1s\n  1100K .......... .......... .......... .......... .......... 11% 16.7M 1s\n  1150K .......... .......... .......... .......... .......... 11% 54.5M 1s\n  1200K .......... .......... .......... .......... .......... 12% 53.0M 1s\n  1250K .......... .......... .......... .......... .......... 12% 49.5M 1s\n  1300K .......... .......... .......... .......... .......... 13% 50.9M 1s\n  1350K .......... .......... .......... .......... .......... 13% 48.9M 0s\n  1400K .......... .......... .......... .......... .......... 14% 46.5M 0s\n  1450K .......... .......... .......... .......... .......... 14% 54.0M 0s\n  1500K .......... .......... .......... .......... .......... 15% 55.7M 0s\n  1550K .......... .......... .......... .......... .......... 15% 48.6M 0s\n  1600K .......... .......... .......... .......... .......... 16% 53.3M 0s\n  1650K .......... .......... .......... .......... .......... 16% 52.0M 0s\n  1700K .......... .......... .......... .......... .......... 17% 58.3M 0s\n  1750K .......... .......... .......... .......... .......... 17% 56.9M 0s\n  1800K .......... .......... .......... .......... .......... 18% 43.1M 0s\n  1850K .......... .......... .......... .......... .......... 18% 51.3M 0s\n  1900K .......... .......... .......... .......... .......... 19% 67.6M 0s\n  1950K .......... .......... .......... .......... .......... 19% 51.8M 0s\n  2000K .......... .......... .......... .......... .......... 20% 57.1M 0s\n  2050K .......... .......... .......... .......... .......... 20% 51.1M 0s\n  2100K .......... .......... .......... .......... .......... 21% 58.4M 0s\n  2150K .......... .......... .......... .......... .......... 21% 55.3M 0s\n  2200K .......... .......... .......... .......... .......... 22% 43.9M 0s\n  2250K .......... .......... .......... .......... .......... 22% 60.8M 0s\n  2300K .......... .......... .......... .......... .......... 23% 55.0M 0s\n  2350K .......... .......... .......... .......... .......... 23% 54.1M 0s\n  2400K .......... .......... .......... .......... .......... 24% 53.7M 0s\n  2450K .......... .......... .......... .......... .......... 24% 54.7M 0s\n  2500K .......... .......... .......... .......... .......... 25% 52.6M 0s\n  2550K .......... .......... .......... .......... .......... 25% 61.6M 0s\n  2600K .......... .......... .......... .......... .......... 26% 36.3M 0s\n  2650K .......... .......... .......... .......... .......... 26% 53.2M 0s\n  2700K .......... .......... .......... .......... .......... 27% 50.1M 0s\n  2750K .......... .......... .......... .......... .......... 27% 56.1M 0s\n  2800K .......... .......... .......... .......... .......... 28% 56.2M 0s\n  2850K .......... .......... .......... .......... .......... 28% 54.0M 0s\n  2900K .......... .......... .......... .......... .......... 29% 50.0M 0s\n  2950K .......... .......... .......... .......... .......... 29% 60.9M 0s\n  3000K .......... .......... .......... .......... .......... 30% 39.5M 0s\n  3050K .......... .......... .......... .......... .......... 30% 56.1M 0s\n  3100K .......... .......... .......... .......... .......... 31% 53.6M 0s\n  3150K .......... .......... .......... .......... .......... 31% 49.3M 0s\n  3200K .......... .......... .......... .......... .......... 32% 53.9M 0s\n  3250K .......... .......... .......... .......... .......... 32% 56.0M 0s\n  3300K .......... .......... .......... .......... .......... 33% 57.5M 0s\n  3350K .......... .......... .......... .......... .......... 33% 57.2M 0s\n  3400K .......... .......... .......... .......... .......... 34% 41.3M 0s\n  3450K .......... .......... .......... .......... .......... 34% 56.0M 0s\n  3500K .......... .......... .......... .......... .......... 35% 60.0M 0s\n  3550K .......... .......... .......... .......... .......... 35% 55.0M 0s\n  3600K .......... .......... .......... .......... .......... 36% 50.5M 0s\n  3650K .......... .......... .......... .......... .......... 36% 60.2M 0s\n  3700K .......... .......... .......... .......... .......... 37% 56.6M 0s\n  3750K .......... .......... .......... .......... .......... 37% 52.5M 0s\n  3800K .......... .......... .......... .......... .......... 38% 41.9M 0s\n  3850K .......... .......... .......... .......... .......... 38% 51.1M 0s\n  3900K .......... .......... .......... .......... .......... 39% 47.7M 0s\n  3950K .......... .......... .......... .......... .......... 39% 53.6M 0s\n  4000K .......... .......... .......... .......... .......... 40% 53.5M 0s\n  4050K .......... .......... .......... .......... .......... 40% 56.1M 0s\n  4100K .......... .......... .......... .......... .......... 41% 57.7M 0s\n  4150K .......... .......... .......... .......... .......... 41% 58.0M 0s\n  4200K .......... .......... .......... .......... .......... 42% 39.3M 0s\n  4250K .......... .......... .......... .......... .......... 42% 54.6M 0s\n  4300K .......... .......... .......... .......... .......... 43% 53.8M 0s\n  4350K .......... .......... .......... .......... .......... 43% 59.6M 0s\n  4400K .......... .......... .......... .......... .......... 44% 49.4M 0s\n  4450K .......... .......... .......... .......... .......... 44% 55.9M 0s\n  4500K .......... .......... .......... .......... .......... 45% 51.5M 0s\n  4550K .......... .......... .......... .......... .......... 45% 58.9M 0s\n  4600K .......... .......... .......... .......... .......... 46% 43.4M 0s\n  4650K .......... .......... .......... .......... .......... 46% 55.4M 0s\n  4700K .......... .......... .......... .......... .......... 47% 57.8M 0s\n  4750K .......... .......... .......... .......... .......... 47% 49.5M 0s\n  4800K .......... .......... .......... .......... .......... 48% 59.3M 0s\n  4850K .......... .......... .......... .......... .......... 48% 54.2M 0s\n  4900K .......... .......... .......... .......... .......... 49% 53.2M 0s\n  4950K .......... .......... .......... .......... .......... 49% 56.7M 0s\n  5000K .......... .......... .......... .......... .......... 50% 41.2M 0s\n  5050K .......... .......... .......... .......... .......... 50% 59.4M 0s\n  5100K .......... .......... .......... .......... .......... 51% 53.0M 0s\n  5150K .......... .......... .......... .......... .......... 51% 58.5M 0s\n  5200K .......... .......... .......... .......... .......... 52% 52.3M 0s\n  5250K .......... .......... .......... .......... .......... 52% 49.5M 0s\n  5300K .......... .......... .......... .......... .......... 53% 46.0M 0s\n  5350K .......... .......... .......... .......... .......... 53% 56.4M 0s\n  5400K .......... .......... .......... .......... .......... 54% 41.3M 0s\n  5450K .......... .......... .......... .......... .......... 54% 55.0M 0s\n  5500K .......... .......... .......... .......... .......... 55% 53.6M 0s\n  5550K .......... .......... .......... .......... .......... 55% 51.1M 0s\n  5600K .......... .......... .......... .......... .......... 56% 51.0M 0s\n  5650K .......... .......... .......... .......... .......... 56% 51.2M 0s\n  5700K .......... .......... .......... .......... .......... 57% 52.6M 0s\n  5750K .......... .......... .......... .......... .......... 57% 59.1M 0s\n  5800K .......... .......... .......... .......... .......... 58% 39.6M 0s\n  5850K .......... .......... .......... .......... .......... 58% 58.0M 0s\n  5900K .......... .......... .......... .......... .......... 59% 55.8M 0s\n  5950K .......... .......... .......... .......... .......... 59% 55.8M 0s\n  6000K .......... .......... .......... .......... .......... 60% 49.0M 0s\n  6050K .......... .......... .......... .......... .......... 60% 55.6M 0s\n  6100K .......... .......... .......... .......... .......... 61% 48.4M 0s\n  6150K .......... .......... .......... .......... .......... 61% 69.5M 0s\n  6200K .......... .......... .......... .......... .......... 62% 43.1M 0s\n  6250K .......... .......... .......... .......... .......... 62% 57.5M 0s\n  6300K .......... .......... .......... .......... .......... 63% 57.3M 0s\n  6350K .......... .......... .......... .......... .......... 63% 49.9M 0s\n  6400K .......... .......... .......... .......... .......... 64% 58.5M 0s\n  6450K .......... .......... .......... .......... .......... 64% 49.7M 0s\n  6500K .......... .......... .......... .......... .......... 65% 57.9M 0s\n  6550K .......... .......... .......... .......... .......... 65% 55.8M 0s\n  6600K .......... .......... .......... .......... .......... 66% 38.1M 0s\n  6650K .......... .......... .......... .......... .......... 66% 54.4M 0s\n  6700K .......... .......... .......... .......... .......... 67% 48.6M 0s\n  6750K .......... .......... .......... .......... .......... 67% 56.8M 0s\n  6800K .......... .......... .......... .......... .......... 68% 51.4M 0s\n  6850K .......... .......... .......... .......... .......... 68% 59.6M 0s\n  6900K .......... .......... .......... .......... .......... 69% 50.5M 0s\n  6950K .......... .......... .......... .......... .......... 69% 54.2M 0s\n  7000K .......... .......... .......... .......... .......... 70% 42.1M 0s\n  7050K .......... .......... .......... .......... .......... 70% 55.4M 0s\n  7100K .......... .......... .......... .......... .......... 71% 57.4M 0s\n  7150K .......... .......... .......... .......... .......... 71% 51.0M 0s\n  7200K .......... .......... .......... .......... .......... 72% 55.8M 0s\n  7250K .......... .......... .......... .......... .......... 72% 56.2M 0s\n  7300K .......... .......... .......... .......... .......... 73% 58.1M 0s\n  7350K .......... .......... .......... .......... .......... 73% 57.2M 0s\n  7400K .......... .......... .......... .......... .......... 74% 41.4M 0s\n  7450K .......... .......... .......... .......... .......... 74% 57.8M 0s\n  7500K .......... .......... .......... .......... .......... 75% 59.6M 0s\n  7550K .......... .......... .......... .......... .......... 75% 57.4M 0s\n  7600K .......... .......... .......... .......... .......... 76% 53.9M 0s\n  7650K .......... .......... .......... .......... .......... 76% 48.5M 0s\n  7700K .......... .......... .......... .......... .......... 77% 63.3M 0s\n  7750K .......... .......... .......... .......... .......... 77% 55.8M 0s\n  7800K .......... .......... .......... .......... .......... 78% 46.1M 0s\n  7850K .......... .......... .......... .......... .......... 78% 56.9M 0s\n  7900K .......... .......... .......... .......... .......... 79% 53.1M 0s\n  7950K .......... .......... .......... .......... .......... 79% 45.5M 0s\n  8000K .......... .......... .......... .......... .......... 79% 46.5M 0s\n  8050K .......... .......... .......... .......... .......... 80% 56.9M 0s\n  8100K .......... .......... .......... .......... .......... 80% 58.0M 0s\n  8150K .......... .......... .......... .......... .......... 81% 44.2M 0s\n  8200K .......... .......... .......... .......... .......... 81% 38.1M 0s\n  8250K .......... .......... .......... .......... .......... 82% 53.1M 0s\n  8300K .......... .......... .......... .......... .......... 82% 51.2M 0s\n  8350K .......... .......... .......... .......... .......... 83% 54.2M 0s\n  8400K .......... .......... .......... .......... .......... 83% 52.4M 0s\n  8450K .......... .......... .......... .......... .......... 84% 55.3M 0s\n  8500K .......... .......... .......... .......... .......... 84% 55.9M 0s\n  8550K .......... .......... .......... .......... .......... 85% 56.6M 0s\n  8600K .......... .......... .......... .......... .......... 85% 44.9M 0s\n  8650K .......... .......... .......... .......... .......... 86% 56.5M 0s\n  8700K .......... .......... .......... .......... .......... 86% 60.1M 0s\n  8750K .......... .......... .......... .......... .......... 87% 40.8M 0s\n  8800K .......... .......... .......... .......... .......... 87% 51.7M 0s\n  8850K .......... .......... .......... .......... .......... 88% 54.6M 0s\n  8900K .......... .......... .......... .......... .......... 88% 67.2M 0s\n  8950K .......... .......... .......... .......... .......... 89% 48.6M 0s\n  9000K .......... .......... .......... .......... .......... 89% 45.5M 0s\n  9050K .......... .......... .......... .......... .......... 90% 55.7M 0s\n  9100K .......... .......... .......... .......... .......... 90% 55.8M 0s\n  9150K .......... .......... .......... .......... .......... 91% 55.4M 0s\n  9200K .......... .......... .......... .......... .......... 91% 51.3M 0s\n  9250K .......... .......... .......... .......... .......... 92% 43.4M 0s\n  9300K .......... .......... .......... .......... .......... 92% 65.4M 0s\n  9350K .......... .......... .......... .......... .......... 93% 63.8M 0s\n  9400K .......... .......... .......... .......... .......... 93% 43.0M 0s\n  9450K .......... .......... .......... .......... .......... 94% 56.4M 0s\n  9500K .......... .......... .......... .......... .......... 94% 53.5M 0s\n  9550K .......... .......... .......... .......... .......... 95% 44.1M 0s\n  9600K .......... .......... .......... .......... .......... 95% 50.4M 0s\n  9650K .......... .......... .......... .......... .......... 96% 51.5M 0s\n  9700K .......... .......... .......... .......... .......... 96% 62.9M 0s\n  9750K .......... .......... .......... .......... .......... 97% 60.5M 0s\n  9800K .......... .......... .......... .......... .......... 97% 41.8M 0s\n  9850K .......... .......... .......... .......... .......... 98% 57.7M 0s\n  9900K .......... .......... .......... .......... .......... 98% 50.2M 0s\n  9950K .......... .......... .......... .......... .......... 99% 54.4M 0s\n 10000K .......... .......... .......... .......... .......... 99% 55.3M 0s\n 10050K .......... ...                                        100%  211M=0.2s\n\n2019-01-30 14:16:04 (40.9 MB/s) - \u2018osquery_3.3.0_1.linux.amd64.deb\u2019 saved [10304582/10304582]\n\n",
+        "StandardErrorUrl": "",
+        "CloudWatchOutputConfig": {
+            "CloudWatchLogGroupName": "",
+            "CloudWatchOutputEnabled": false
+        },
+        "ResponseMetadata": {
+            "RequestId": "a7127c91-d3c7-47a1-8b42-82320196d6b0",
+            "HTTPStatusCode": 200,
+            "HTTPHeaders": {
+                "x-amzn-requestid": "a7127c91-d3c7-47a1-8b42-82320196d6b0",
+                "content-type": "application/x-amz-json-1.1",
+                "content-length": "17484",
+                "date": "Wed, 30 Jan 2019 14:16:08 GMT"
+            },
+            "RetryAttempts": 0
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_ssm_send_command/ssm.SendCommand_1.json b/tests/data/placebo/test_ssm_send_command/ssm.SendCommand_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_ssm_send_command/ssm.SendCommand_1.json
@@ -0,0 +1,72 @@
+{
+    "status_code": 200,
+    "data": {
+        "Command": {
+            "CommandId": "139fedb0-4913-47da-bb53-c08364f07c22",
+            "DocumentName": "AWS-RunShellScript",
+            "DocumentVersion": "",
+            "Comment": "",
+            "ExpiresAfter": {
+                "__class__": "datetime",
+                "year": 2019,
+                "month": 1,
+                "day": 30,
+                "hour": 11,
+                "minute": 16,
+                "second": 3,
+                "microsecond": 50000
+            },
+            "Parameters": {
+                "commands": [
+                    "wget https://pkg.osquery.io/deb/osquery_3.3.0_1.linux.amd64.deb",
+                    "dpkg -i osquery_3.3.0_1.linux.amd64.deb"
+                ]
+            },
+            "InstanceIds": [
+                "i-0ba3874e85bb97244"
+            ],
+            "Targets": [],
+            "RequestedDateTime": {
+                "__class__": "datetime",
+                "year": 2019,
+                "month": 1,
+                "day": 30,
+                "hour": 9,
+                "minute": 16,
+                "second": 3,
+                "microsecond": 50000
+            },
+            "Status": "Pending",
+            "StatusDetails": "Pending",
+            "OutputS3BucketName": "",
+            "OutputS3KeyPrefix": "",
+            "MaxConcurrency": "50",
+            "MaxErrors": "0",
+            "TargetCount": 1,
+            "CompletedCount": 0,
+            "ErrorCount": 0,
+            "DeliveryTimedOutCount": 0,
+            "ServiceRole": "",
+            "NotificationConfig": {
+                "NotificationArn": "",
+                "NotificationEvents": [],
+                "NotificationType": ""
+            },
+            "CloudWatchOutputConfig": {
+                "CloudWatchLogGroupName": "",
+                "CloudWatchOutputEnabled": false
+            }
+        },
+        "ResponseMetadata": {
+            "RequestId": "fe83472c-f294-4b3f-9652-5ea1e74981e4",
+            "HTTPStatusCode": 200,
+            "HTTPHeaders": {
+                "x-amzn-requestid": "fe83472c-f294-4b3f-9652-5ea1e74981e4",
+                "content-type": "application/x-amz-json-1.1",
+                "content-length": "808",
+                "date": "Wed, 30 Jan 2019 14:16:02 GMT"
+            },
+            "RetryAttempts": 0
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/test_ssm.py b/tests/test_ssm.py
--- a/tests/test_ssm.py
+++ b/tests/test_ssm.py
@@ -13,11 +13,53 @@
 # limitations under the License.
 from __future__ import absolute_import, division, print_function, unicode_literals
 
+from c7n.exceptions import PolicyValidationError
 from .common import BaseTest, functional
 
+import time
+
 
 class TestSsm(BaseTest):
 
+    def test_ec2_ssm_send_command_validate(self):
+        self.assertRaises(
+            PolicyValidationError,
+            self.load_policy,
+            {'name': 'ssm-instances',
+             'resource': 'aws.ec2',
+             'actions': [
+                 {'type': 'send-command',
+                  'command': {
+                      'DocumentName': 'AWS-RunShellScript'}}]},
+            validate=True)
+
+    def test_ssm_send_command(self):
+        factory = self.replay_flight_data('test_ssm_send_command')
+        p = self.load_policy({
+            'name': 'ssm-instances',
+            'resource': 'ssm-managed-instance',
+            'filters': [{"PingStatus": "Online"}],
+            'actions': [
+                {'type': 'send-command',
+                 'command': {
+                     'DocumentName': 'AWS-RunShellScript',
+                     'Parameters': {
+                         'commands': [
+                             'wget https://pkg.osquery.io/deb/osquery_3.3.0_1.linux.amd64.deb',
+                             'dpkg -i osquery_3.3.0_1.linux.amd64.deb']}}}]},
+            session_factory=factory, config={'region': 'us-east-2'})
+        resources = p.run()
+        self.assertEqual(len(resources), 1)
+        self.assertTrue('c7n:SendCommand' in resources[0])
+
+        if self.recording:
+            time.sleep(5)
+
+        result = factory().client('ssm').get_command_invocation(
+            InstanceId=resources[0]['InstanceId'],
+            CommandId=resources[0]['c7n:SendCommand'][0])
+        self.assertEqual(result['Status'], 'Success')
+
     @functional
     def test_ssm_parameter_not_secure(self):
         session_factory = self.replay_flight_data("test_ssm_parameter_not_secure")