Repository: cloud-custodian/cloud-custodian

Issue:
DMS resource support
As DMS (Database Migration Service) supports tagging per http://boto3.readthedocs.io/en/latest/reference/services/dms.html#DatabaseMigrationService.Client.add_tags_to_resource and this can be a non-trivial cost, I have a client who is interested in this being a supported resource


Discussion:
is that across all the dms service resources ie. 

- replication instance
- endpoint
- security group
- migration task. 
Replication instance is what they are paying for, so that is the highest priority.  Others are just nice to haves.
A specific example of a policy needed is to action DeleteReplicationInstance and Notify when DescribeReplicationInstances returns a resource where PublicalyAccessible is true.

Resolving patch:
diff --git a/c7n/resources/__init__.py b/c7n/resources/__init__.py
--- a/c7n/resources/__init__.py
+++ b/c7n/resources/__init__.py
@@ -45,6 +45,7 @@ def load_resources():
     import c7n.resources.cw
     import c7n.resources.directory
     import c7n.resources.directconnect
+    import c7n.resources.dms
     import c7n.resources.dynamodb
     import c7n.resources.datapipeline
     import c7n.resources.ebs
diff --git a/c7n/resources/dms.py b/c7n/resources/dms.py
new file mode 100644
--- /dev/null
+++ b/c7n/resources/dms.py
@@ -0,0 +1,91 @@
+# Copyright 2017 Capital One Services, LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from botocore.exceptions import ClientError
+from concurrent.futures import as_completed
+
+from c7n.actions import BaseAction
+from c7n.manager import resources
+from c7n.query import QueryResourceManager, DescribeSource
+from c7n.utils import local_session, chunks, type_schema
+
+
+@resources.register('dms-instance')
+class ReplicationInstance(QueryResourceManager):
+
+    class resource_type(object):
+        service = 'dms'
+        type = 'rep'
+        enum_spec = ('describe_replication_instances', 'ReplicationInstances', None)
+        name = id = 'ReplicationInstanceIdentifier'
+        date = 'InstanceCreateTime'
+        dimension = None
+
+        # The api supports filtering which we handle via custom describe source.
+        filter_name = filter_type = None
+
+    def get_source(self, source_type):
+        if source_type == 'describe':
+            return InstanceDescribe(self)
+        return super(ReplicationInstance, self).get_source(source_type)
+
+    def get_arns(self, resources):
+        return [r['ReplicationInstanceArn'] for r in resources]
+
+
+class InstanceDescribe(DescribeSource):
+
+    def get_resources(self, resource_ids):
+        return self.query.filter(
+            self.manager,
+            **{
+                'Filters': [
+                    {'Name': 'replication-instance-id', 'Values': resource_ids}]})
+
+    def augment(self, resources):
+        client = local_session(self.manager.session_factory).client('dms')
+        with self.manager.executor_factory(max_workers=2) as w:
+            futures = []
+            for resource_set in chunks(resources, 20):
+                futures.append(w.submit(self.process_resource_set, client, resources))
+
+            for f in as_completed(futures):
+                if f.exception():
+                    self.manager.log.warning(
+                        "Error retrieving replinstance tags: %s" % f.exception())
+        return resources
+
+    def process_resource_set(self, client, resources):
+        for arn, r in zip(self.manager.get_arns(resources), resources):
+            self.manager.log.info("arn %s" % arn)
+            try:
+                tags = client.list_tags_for_resource(
+                    ResourceArn=arn).get('TagList', ())
+            except ClientError as e:
+                if e.response['Error']['Code'] == 'ResourceNotFoundFault':
+                    continue
+                raise
+            r['Tags'] = tags
+
+
+@ReplicationInstance.action_registry.register('delete')
+class InstanceDelete(BaseAction):
+
+    schema = type_schema('delete')
+    permissions = ('dms:DeleteReplicationInstance',)
+
+    def process(self, resources):
+        client = local_session(self.manager.session_factory).client('dms')
+        for arn, r in zip(self.manager.get_arns(resources), resources):
+            client.delete_replication_instance(ReplicationInstanceArn=arn)


Test patch:
diff --git a/tests/data/placebo/test_dms_repl_instance_delete/dms.DeleteReplicationInstance_1.json b/tests/data/placebo/test_dms_repl_instance_delete/dms.DeleteReplicationInstance_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_dms_repl_instance_delete/dms.DeleteReplicationInstance_1.json
@@ -0,0 +1,91 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ReplicationInstance": {
+            "MultiAZ": false, 
+            "AvailabilityZone": "us-east-1b", 
+            "ReplicationInstancePrivateIpAddress": "172.31.27.105", 
+            "ReplicationInstanceArn": "arn:aws:dms:us-east-1:644160558196:rep:NNH7KJHLE6R7HAL7BZWOVUQHZY", 
+            "ReplicationInstancePrivateIpAddresses": [
+                "172.31.27.105"
+            ], 
+            "ReplicationInstanceClass": "dms.t2.medium", 
+            "ReplicationSubnetGroup": {
+                "ReplicationSubnetGroupDescription": "default group created by console for vpc id vpc-d2d616b5", 
+                "Subnets": [
+                    {
+                        "SubnetStatus": "Active", 
+                        "SubnetIdentifier": "subnet-3a334610", 
+                        "SubnetAvailabilityZone": {
+                            "Name": "us-east-1d"
+                        }
+                    }, 
+                    {
+                        "SubnetStatus": "Active", 
+                        "SubnetIdentifier": "subnet-efbcccb7", 
+                        "SubnetAvailabilityZone": {
+                            "Name": "us-east-1b"
+                        }
+                    }, 
+                    {
+                        "SubnetStatus": "Active", 
+                        "SubnetIdentifier": "subnet-e3b194de", 
+                        "SubnetAvailabilityZone": {
+                            "Name": "us-east-1e"
+                        }
+                    }, 
+                    {
+                        "SubnetStatus": "Active", 
+                        "SubnetIdentifier": "subnet-914763e7", 
+                        "SubnetAvailabilityZone": {
+                            "Name": "us-east-1a"
+                        }
+                    }
+                ], 
+                "VpcId": "vpc-d2d616b5", 
+                "SubnetGroupStatus": "Complete", 
+                "ReplicationSubnetGroupIdentifier": "default-vpc-d2d616b5"
+            }, 
+            "AutoMinorVersionUpgrade": true, 
+            "ReplicationInstanceStatus": "deleting", 
+            "VpcSecurityGroups": [
+                {
+                    "Status": "active", 
+                    "VpcSecurityGroupId": "sg-c63712b4"
+                }
+            ], 
+            "KmsKeyId": "arn:aws:kms:us-east-1:644160558196:key/f1f33a6b-91aa-4b0a-904c-f2a0378277f0", 
+            "InstanceCreateTime": {
+                "hour": 5, 
+                "__class__": "datetime", 
+                "month": 10, 
+                "second": 18, 
+                "microsecond": 283000, 
+                "year": 2017, 
+                "day": 31, 
+                "minute": 6
+            }, 
+            "ReplicationInstancePublicIpAddress": "54.156.233.85", 
+            "AllocatedStorage": 50, 
+            "EngineVersion": "2.3.0", 
+            "ReplicationInstancePublicIpAddresses": [
+                "54.156.233.85"
+            ], 
+            "ReplicationInstanceIdentifier": "replication-instance-1", 
+            "PubliclyAccessible": true, 
+            "PreferredMaintenanceWindow": "wed:23:08-wed:23:38", 
+            "PendingModifiedValues": {}
+        }, 
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "51a71ad6-be26-11e7-88fb-33b14e65bc19", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "51a71ad6-be26-11e7-88fb-33b14e65bc19", 
+                "date": "Tue, 31 Oct 2017 10:29:04 GMT", 
+                "content-length": "1807", 
+                "content-type": "application/x-amz-json-1.1"
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_dms_repl_instance_delete/dms.DescribeReplicationInstances_1.json b/tests/data/placebo/test_dms_repl_instance_delete/dms.DescribeReplicationInstances_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_dms_repl_instance_delete/dms.DescribeReplicationInstances_1.json
@@ -0,0 +1,93 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "517e84d8-be26-11e7-a0f2-376813db7035", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "517e84d8-be26-11e7-a0f2-376813db7035", 
+                "date": "Tue, 31 Oct 2017 10:29:04 GMT", 
+                "content-length": "1811", 
+                "content-type": "application/x-amz-json-1.1"
+            }
+        }, 
+        "ReplicationInstances": [
+            {
+                "MultiAZ": false, 
+                "AvailabilityZone": "us-east-1b", 
+                "ReplicationInstancePrivateIpAddress": "172.31.27.105", 
+                "ReplicationInstanceArn": "arn:aws:dms:us-east-1:644160558196:rep:NNH7KJHLE6R7HAL7BZWOVUQHZY", 
+                "ReplicationInstancePrivateIpAddresses": [
+                    "172.31.27.105"
+                ], 
+                "ReplicationInstanceClass": "dms.t2.medium", 
+                "ReplicationSubnetGroup": {
+                    "ReplicationSubnetGroupDescription": "default group created by console for vpc id vpc-d2d616b5", 
+                    "Subnets": [
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-3a334610", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1d"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-efbcccb7", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1b"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-e3b194de", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1e"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-914763e7", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1a"
+                            }
+                        }
+                    ], 
+                    "VpcId": "vpc-d2d616b5", 
+                    "SubnetGroupStatus": "Complete", 
+                    "ReplicationSubnetGroupIdentifier": "default-vpc-d2d616b5"
+                }, 
+                "AutoMinorVersionUpgrade": true, 
+                "ReplicationInstanceStatus": "available", 
+                "VpcSecurityGroups": [
+                    {
+                        "Status": "active", 
+                        "VpcSecurityGroupId": "sg-c63712b4"
+                    }
+                ], 
+                "KmsKeyId": "arn:aws:kms:us-east-1:644160558196:key/f1f33a6b-91aa-4b0a-904c-f2a0378277f0", 
+                "InstanceCreateTime": {
+                    "hour": 5, 
+                    "__class__": "datetime", 
+                    "month": 10, 
+                    "second": 18, 
+                    "microsecond": 283000, 
+                    "year": 2017, 
+                    "day": 31, 
+                    "minute": 6
+                }, 
+                "ReplicationInstancePublicIpAddress": "54.156.233.85", 
+                "AllocatedStorage": 50, 
+                "EngineVersion": "2.3.0", 
+                "ReplicationInstancePublicIpAddresses": [
+                    "54.156.233.85"
+                ], 
+                "ReplicationInstanceIdentifier": "replication-instance-1", 
+                "PubliclyAccessible": true, 
+                "PreferredMaintenanceWindow": "wed:23:08-wed:23:38", 
+                "PendingModifiedValues": {}
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_dms_repl_instance_delete/dms.DescribeReplicationInstances_2.json b/tests/data/placebo/test_dms_repl_instance_delete/dms.DescribeReplicationInstances_2.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_dms_repl_instance_delete/dms.DescribeReplicationInstances_2.json
@@ -0,0 +1,93 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "51c81067-be26-11e7-bad3-e94762008cb4", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "51c81067-be26-11e7-bad3-e94762008cb4", 
+                "date": "Tue, 31 Oct 2017 10:29:04 GMT", 
+                "content-length": "1810", 
+                "content-type": "application/x-amz-json-1.1"
+            }
+        }, 
+        "ReplicationInstances": [
+            {
+                "MultiAZ": false, 
+                "AvailabilityZone": "us-east-1b", 
+                "ReplicationInstancePrivateIpAddress": "172.31.27.105", 
+                "ReplicationInstanceArn": "arn:aws:dms:us-east-1:644160558196:rep:NNH7KJHLE6R7HAL7BZWOVUQHZY", 
+                "ReplicationInstancePrivateIpAddresses": [
+                    "172.31.27.105"
+                ], 
+                "ReplicationInstanceClass": "dms.t2.medium", 
+                "ReplicationSubnetGroup": {
+                    "ReplicationSubnetGroupDescription": "default group created by console for vpc id vpc-d2d616b5", 
+                    "Subnets": [
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-3a334610", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1d"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-efbcccb7", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1b"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-e3b194de", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1e"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-914763e7", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1a"
+                            }
+                        }
+                    ], 
+                    "VpcId": "vpc-d2d616b5", 
+                    "SubnetGroupStatus": "Complete", 
+                    "ReplicationSubnetGroupIdentifier": "default-vpc-d2d616b5"
+                }, 
+                "AutoMinorVersionUpgrade": true, 
+                "ReplicationInstanceStatus": "deleting", 
+                "VpcSecurityGroups": [
+                    {
+                        "Status": "active", 
+                        "VpcSecurityGroupId": "sg-c63712b4"
+                    }
+                ], 
+                "KmsKeyId": "arn:aws:kms:us-east-1:644160558196:key/f1f33a6b-91aa-4b0a-904c-f2a0378277f0", 
+                "InstanceCreateTime": {
+                    "hour": 5, 
+                    "__class__": "datetime", 
+                    "month": 10, 
+                    "second": 18, 
+                    "microsecond": 283000, 
+                    "year": 2017, 
+                    "day": 31, 
+                    "minute": 6
+                }, 
+                "ReplicationInstancePublicIpAddress": "54.156.233.85", 
+                "AllocatedStorage": 50, 
+                "EngineVersion": "2.3.0", 
+                "ReplicationInstancePublicIpAddresses": [
+                    "54.156.233.85"
+                ], 
+                "ReplicationInstanceIdentifier": "replication-instance-1", 
+                "PubliclyAccessible": true, 
+                "PreferredMaintenanceWindow": "wed:23:08-wed:23:38", 
+                "PendingModifiedValues": {}
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_dms_repl_instance_delete/dms.ListTagsForResource_1.json b/tests/data/placebo/test_dms_repl_instance_delete/dms.ListTagsForResource_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_dms_repl_instance_delete/dms.ListTagsForResource_1.json
@@ -0,0 +1,22 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "51936c69-be26-11e7-a0f2-376813db7035", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "51936c69-be26-11e7-a0f2-376813db7035", 
+                "date": "Tue, 31 Oct 2017 10:29:04 GMT", 
+                "content-length": "78", 
+                "content-type": "application/x-amz-json-1.1"
+            }
+        }, 
+        "TagList": [
+            {
+                "Value": "ReplicationInstance1 description", 
+                "Key": "description"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_dms_repl_instance_describe_sans_tags/dms.DescribeReplicationInstances_1.json b/tests/data/placebo/test_dms_repl_instance_describe_sans_tags/dms.DescribeReplicationInstances_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_dms_repl_instance_describe_sans_tags/dms.DescribeReplicationInstances_1.json
@@ -0,0 +1,93 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "6442355e-be24-11e7-ac45-a153ccfdbc14", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "6442355e-be24-11e7-ac45-a153ccfdbc14", 
+                "date": "Tue, 31 Oct 2017 10:15:16 GMT", 
+                "content-length": "1811", 
+                "content-type": "application/x-amz-json-1.1"
+            }
+        }, 
+        "ReplicationInstances": [
+            {
+                "MultiAZ": false, 
+                "AvailabilityZone": "us-east-1b", 
+                "ReplicationInstancePrivateIpAddress": "172.31.27.105", 
+                "ReplicationInstanceArn": "arn:aws:dms:us-east-1:644160558196:rep:NNH7KJHLE6R7HAL7BZWOVUQHZY", 
+                "ReplicationInstancePrivateIpAddresses": [
+                    "172.31.27.105"
+                ], 
+                "ReplicationInstanceClass": "dms.t2.medium", 
+                "ReplicationSubnetGroup": {
+                    "ReplicationSubnetGroupDescription": "default group created by console for vpc id vpc-d2d616b5", 
+                    "Subnets": [
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-3a334610", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1d"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-efbcccb7", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1b"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-e3b194de", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1e"
+                            }
+                        }, 
+                        {
+                            "SubnetStatus": "Active", 
+                            "SubnetIdentifier": "subnet-914763e7", 
+                            "SubnetAvailabilityZone": {
+                                "Name": "us-east-1a"
+                            }
+                        }
+                    ], 
+                    "VpcId": "vpc-d2d616b5", 
+                    "SubnetGroupStatus": "Complete", 
+                    "ReplicationSubnetGroupIdentifier": "default-vpc-d2d616b5"
+                }, 
+                "AutoMinorVersionUpgrade": true, 
+                "ReplicationInstanceStatus": "available", 
+                "VpcSecurityGroups": [
+                    {
+                        "Status": "active", 
+                        "VpcSecurityGroupId": "sg-c63712b4"
+                    }
+                ], 
+                "KmsKeyId": "arn:aws:kms:us-east-1:644160558196:key/f1f33a6b-91aa-4b0a-904c-f2a0378277f0", 
+                "InstanceCreateTime": {
+                    "hour": 5, 
+                    "__class__": "datetime", 
+                    "month": 10, 
+                    "second": 18, 
+                    "microsecond": 283000, 
+                    "year": 2017, 
+                    "day": 31, 
+                    "minute": 6
+                }, 
+                "ReplicationInstancePublicIpAddress": "54.156.233.85", 
+                "AllocatedStorage": 50, 
+                "EngineVersion": "2.3.0", 
+                "ReplicationInstancePublicIpAddresses": [
+                    "54.156.233.85"
+                ], 
+                "ReplicationInstanceIdentifier": "replication-instance-1", 
+                "PubliclyAccessible": true, 
+                "PreferredMaintenanceWindow": "wed:23:08-wed:23:38", 
+                "PendingModifiedValues": {}
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_dms_repl_instance_describe_sans_tags/dms.ListTagsForResource_1.json b/tests/data/placebo/test_dms_repl_instance_describe_sans_tags/dms.ListTagsForResource_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_dms_repl_instance_describe_sans_tags/dms.ListTagsForResource_1.json
@@ -0,0 +1,21 @@
+{
+    "status_code": 400, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 400, 
+            "RequestId": "66b72d1e-be24-11e7-89b8-5b94ccffd854", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "66b72d1e-be24-11e7-89b8-5b94ccffd854", 
+                "date": "Tue, 31 Oct 2017 10:15:20 GMT", 
+                "content-length": "173", 
+                "content-type": "application/x-amz-json-1.1", 
+                "connection": "close"
+            }
+        }, 
+        "Error": {
+            "Message": "Could not find a ReplicationInstance matching the resource name: arn:aws:dms:us-east-1:644160558196:rep:replication-instance-1", 
+            "Code": "ResourceNotFoundFault"
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/test_dms.py b/tests/test_dms.py
new file mode 100644
--- /dev/null
+++ b/tests/test_dms.py
@@ -0,0 +1,62 @@
+# Copyright 2017 Capital One Services, LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .common import BaseTest
+
+class ReplInstance(BaseTest):
+
+    def test_describe_augment_no_tags(self):
+        session_factory = self.replay_flight_data(
+            'test_dms_repl_instance_describe_sans_tags')
+        p = self.load_policy({
+            'name': 'dms-replinstance',
+            'resource': 'dms-instance'},
+            session_factory=session_factory)        
+        resources = p.run()
+        self.assertEqual(len(resources), 1)
+        self.assertEqual(resources[0]['ReplicationInstanceIdentifier'],
+                         'replication-instance-1')
+
+    def test_describe_get_resources(self):
+        session_factory = self.replay_flight_data(
+            'test_dms_repl_instance_delete')
+        p = self.load_policy({
+            'name': 'dms-replinstance',
+            'resource': 'dms-instance'},
+            session_factory=session_factory)        
+        resources = p.resource_manager.get_resources(
+            ['replication-instance-1'])
+        self.assertEqual(len(resources), 1)
+        self.assertEqual(resources[0]['ReplicationInstanceIdentifier'],
+                         'replication-instance-1')        
+
+    def test_delete(self):
+        session_factory = self.replay_flight_data(
+            'test_dms_repl_instance_delete')
+        client = session_factory().client('dms')
+        p = self.load_policy({
+            'name': 'dms-replinstance',
+            'resource': 'dms-instance',
+            'actions': ['delete']},
+            session_factory=session_factory)        
+        resources = p.run()
+        self.assertEqual(len(resources), 1)
+        self.assertEqual(resources[0]['ReplicationInstanceIdentifier'],
+                         'replication-instance-1')
+        instances = client.describe_replication_instances().get(
+            'ReplicationInstances')
+        self.assertEqual(instances[0]['ReplicationInstanceStatus'], 'deleting')
+        
+        
+