Repository: cloud-custodian/cloud-custodian

Issue:
ASG rename-tag is not propagating new tag name to ec2 instance
https://github.com/capitalone/cloud-custodian/blob/master/c7n/resources/asg.py#L1053

Custodian deletes old tag (source) and creates a new tag (dest) with old tag's key for ec2 instance associated to an asg.

Instead, we need to update Key to reflect the new tag key. 

`        client.create_tags(
            Resources=[i['InstanceId'] for i in asg['Instances']],
            Tags=[{'Key': source['Key'], 'Value': source['Value']}])`

should become 

`        client.create_tags(
            Resources=[i['InstanceId'] for i in asg['Instances']],
            Tags=[{'Key': destination_tag, 'Value': source['Value']}])`




Discussion:
thanks for the bug report.
should also update the test case to verify on a tag rename instead of just a value change https://github.com/capitalone/cloud-custodian/blob/master/tests/test_asg.py#L110

Resolving patch:
diff --git a/c7n/resources/asg.py b/c7n/resources/asg.py
--- a/c7n/resources/asg.py
+++ b/c7n/resources/asg.py
@@ -1044,16 +1044,16 @@ def process_asg(self, asg):
              'Key': destination_tag,
              'Value': source['Value']}])
         if propagate:
-            self.propogate_instance_tag(source, destination_tag, asg)
+            self.propagate_instance_tag(source, destination_tag, asg)
 
-    def propogate_instance_tag(self, source, destination_tag, asg):
+    def propagate_instance_tag(self, source, destination_tag, asg):
         client = local_session(self.manager.session_factory).client('ec2')
         client.delete_tags(
             Resources=[i['InstanceId'] for i in asg['Instances']],
             Tags=[{"Key": source['Key']}])
         client.create_tags(
             Resources=[i['InstanceId'] for i in asg['Instances']],
-            Tags=[{'Key': source['Key'], 'Value': source['Value']}])
+            Tags=[{'Key': destination_tag, 'Value': source['Value']}])
 
 
 @actions.register('mark-for-op')


Test patch:
diff --git a/tests/data/placebo/test_asg_rename/autoscaling.CreateOrUpdateTags_1.json b/tests/data/placebo/test_asg_rename/autoscaling.CreateOrUpdateTags_1.json
--- a/tests/data/placebo/test_asg_rename/autoscaling.CreateOrUpdateTags_1.json
+++ b/tests/data/placebo/test_asg_rename/autoscaling.CreateOrUpdateTags_1.json
@@ -2,8 +2,15 @@
     "status_code": 200, 
     "data": {
         "ResponseMetadata": {
+            "RetryAttempts": 0, 
             "HTTPStatusCode": 200, 
-            "RequestId": "d72ea08a-1521-11e6-9946-710212a5c2b6"
+            "RequestId": "5c5ea1cf-30ec-11e7-8321-49e0e31ba8ab", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "5c5ea1cf-30ec-11e7-8321-49e0e31ba8ab", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT", 
+                "content-length": "223", 
+                "content-type": "text/xml"
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/autoscaling.DeleteTags_1.json b/tests/data/placebo/test_asg_rename/autoscaling.DeleteTags_1.json
--- a/tests/data/placebo/test_asg_rename/autoscaling.DeleteTags_1.json
+++ b/tests/data/placebo/test_asg_rename/autoscaling.DeleteTags_1.json
@@ -2,8 +2,15 @@
     "status_code": 200, 
     "data": {
         "ResponseMetadata": {
+            "RetryAttempts": 0, 
             "HTTPStatusCode": 200, 
-            "RequestId": "d71aca67-1521-11e6-9144-673ef0c2ea51"
+            "RequestId": "5c50e62e-30ec-11e7-8321-49e0e31ba8ab", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "5c50e62e-30ec-11e7-8321-49e0e31ba8ab", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT", 
+                "content-length": "207", 
+                "content-type": "text/xml"
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_1.json b/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_1.json
--- a/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_1.json
+++ b/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_1.json
@@ -3,21 +3,14 @@
     "data": {
         "AutoScalingGroups": [
             {
-                "AutoScalingGroupARN": "arn:aws:autoscaling:us-west-2:619193117841:autoScalingGroup:74979cda-27ca-4e8d-a3e9-a562d37794d6:autoScalingGroupName/CustodianASG", 
-                "HealthCheckGracePeriod": 300, 
+                "AutoScalingGroupARN": "arn:aws:autoscaling:us-east-1:644160558196:autoScalingGroup:c3ba9110-56ea-412e-a6ec-aaec45330901:autoScalingGroupName/scot-asg-test", 
+                "TargetGroupARNs": [], 
                 "SuspendedProcesses": [], 
-                "DesiredCapacity": 3, 
+                "DesiredCapacity": 1, 
                 "Tags": [
                     {
                         "ResourceType": "auto-scaling-group", 
-                        "ResourceId": "CustodianASG", 
-                        "PropagateAtLaunch": true, 
-                        "Value": "GetSome", 
-                        "Key": "CustomerId"
-                    }, 
-                    {
-                        "ResourceType": "auto-scaling-group", 
-                        "ResourceId": "CustodianASG", 
+                        "ResourceId": "scot-asg-test", 
                         "PropagateAtLaunch": true, 
                         "Value": "ubuntu", 
                         "Key": "Platform"
@@ -25,63 +18,54 @@
                 ], 
                 "EnabledMetrics": [], 
                 "LoadBalancerNames": [], 
-                "AutoScalingGroupName": "CustodianASG", 
+                "AutoScalingGroupName": "scot-asg-test", 
                 "DefaultCooldown": 300, 
-                "MinSize": 3, 
+                "MinSize": 1, 
                 "Instances": [
                     {
                         "ProtectedFromScaleIn": false, 
-                        "AvailabilityZone": "us-west-2a", 
-                        "InstanceId": "i-9206fe54", 
-                        "HealthStatus": "Healthy", 
-                        "LifecycleState": "InService", 
-                        "LaunchConfigurationName": "CustodianASGTest"
-                    }, 
-                    {
-                        "ProtectedFromScaleIn": false, 
-                        "AvailabilityZone": "us-west-2b", 
-                        "InstanceId": "i-7b5241a3", 
+                        "AvailabilityZone": "us-east-1d", 
+                        "InstanceId": "i-04ec879cd823dc92a", 
                         "HealthStatus": "Healthy", 
                         "LifecycleState": "InService", 
-                        "LaunchConfigurationName": "CustodianASGTest"
-                    }, 
-                    {
-                        "ProtectedFromScaleIn": false, 
-                        "AvailabilityZone": "us-west-2c", 
-                        "InstanceId": "i-242dd4f9", 
-                        "HealthStatus": "Healthy", 
-                        "LifecycleState": "InService", 
-                        "LaunchConfigurationName": "CustodianASGTest"
+                        "LaunchConfigurationName": "scot-test2"
                     }
                 ], 
-                "MaxSize": 3, 
-                "VPCZoneIdentifier": "subnet-3f9e3d54,subnet-389e3d53,subnet-3e9e3d55", 
+                "MaxSize": 1, 
+                "VPCZoneIdentifier": "subnet-3a334610", 
+                "HealthCheckGracePeriod": 300, 
                 "TerminationPolicies": [
                     "Default"
                 ], 
-                "LaunchConfigurationName": "CustodianASGTest", 
+                "LaunchConfigurationName": "scot-test2", 
                 "CreatedTime": {
-                    "hour": 12, 
+                    "hour": 19, 
                     "__class__": "datetime", 
                     "month": 5, 
-                    "second": 45, 
-                    "microsecond": 395000, 
-                    "year": 2016, 
-                    "day": 8, 
-                    "minute": 12
+                    "second": 10, 
+                    "microsecond": 961000, 
+                    "year": 2017, 
+                    "day": 3, 
+                    "minute": 9
                 }, 
                 "AvailabilityZones": [
-                    "us-west-2c", 
-                    "us-west-2b", 
-                    "us-west-2a"
+                    "us-east-1d"
                 ], 
                 "HealthCheckType": "EC2", 
                 "NewInstancesProtectedFromScaleIn": false
             }
         ], 
         "ResponseMetadata": {
+            "RetryAttempts": 0, 
             "HTTPStatusCode": 200, 
-            "RequestId": "d6d6bca3-1521-11e6-a834-95332944d938"
+            "RequestId": "5bd21868-30ec-11e7-bb00-1547c7e6d37a", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "5bd21868-30ec-11e7-bb00-1547c7e6d37a", 
+                "vary": "Accept-Encoding", 
+                "content-length": "2218", 
+                "content-type": "text/xml", 
+                "date": "Thu, 04 May 2017 17:08:56 GMT"
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_2.json b/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_2.json
--- a/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_2.json
+++ b/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_2.json
@@ -3,85 +3,69 @@
     "data": {
         "AutoScalingGroups": [
             {
-                "AutoScalingGroupARN": "arn:aws:autoscaling:us-west-2:619193117841:autoScalingGroup:74979cda-27ca-4e8d-a3e9-a562d37794d6:autoScalingGroupName/CustodianASG", 
-                "HealthCheckGracePeriod": 300, 
+                "AutoScalingGroupARN": "arn:aws:autoscaling:us-east-1:644160558196:autoScalingGroup:c3ba9110-56ea-412e-a6ec-aaec45330901:autoScalingGroupName/scot-asg-test", 
+                "TargetGroupARNs": [], 
                 "SuspendedProcesses": [], 
-                "DesiredCapacity": 3, 
+                "DesiredCapacity": 1, 
                 "Tags": [
                     {
                         "ResourceType": "auto-scaling-group", 
-                        "ResourceId": "CustodianASG", 
-                        "PropagateAtLaunch": true, 
-                        "Value": "GetSome", 
-                        "Key": "CustomerId"
-                    }, 
-                    {
-                        "ResourceType": "auto-scaling-group", 
-                        "ResourceId": "CustodianASG", 
+                        "ResourceId": "scot-asg-test", 
                         "PropagateAtLaunch": true, 
                         "Value": "ubuntu", 
-                        "Key": "Linux"
+                        "Key": "Platform"
                     }
                 ], 
                 "EnabledMetrics": [], 
                 "LoadBalancerNames": [], 
-                "AutoScalingGroupName": "CustodianASG", 
+                "AutoScalingGroupName": "scot-asg-test", 
                 "DefaultCooldown": 300, 
-                "MinSize": 3, 
+                "MinSize": 1, 
                 "Instances": [
                     {
                         "ProtectedFromScaleIn": false, 
-                        "AvailabilityZone": "us-west-2a", 
-                        "InstanceId": "i-9206fe54", 
-                        "HealthStatus": "Healthy", 
-                        "LifecycleState": "InService", 
-                        "LaunchConfigurationName": "CustodianASGTest"
-                    }, 
-                    {
-                        "ProtectedFromScaleIn": false, 
-                        "AvailabilityZone": "us-west-2b", 
-                        "InstanceId": "i-7b5241a3", 
+                        "AvailabilityZone": "us-east-1d", 
+                        "InstanceId": "i-04ec879cd823dc92a", 
                         "HealthStatus": "Healthy", 
                         "LifecycleState": "InService", 
-                        "LaunchConfigurationName": "CustodianASGTest"
-                    }, 
-                    {
-                        "ProtectedFromScaleIn": false, 
-                        "AvailabilityZone": "us-west-2c", 
-                        "InstanceId": "i-242dd4f9", 
-                        "HealthStatus": "Healthy", 
-                        "LifecycleState": "InService", 
-                        "LaunchConfigurationName": "CustodianASGTest"
+                        "LaunchConfigurationName": "scot-test2"
                     }
                 ], 
-                "MaxSize": 3, 
-                "VPCZoneIdentifier": "subnet-3f9e3d54,subnet-389e3d53,subnet-3e9e3d55", 
+                "MaxSize": 1, 
+                "VPCZoneIdentifier": "subnet-3a334610", 
+                "HealthCheckGracePeriod": 300, 
                 "TerminationPolicies": [
                     "Default"
                 ], 
-                "LaunchConfigurationName": "CustodianASGTest", 
+                "LaunchConfigurationName": "scot-test2", 
                 "CreatedTime": {
-                    "hour": 12, 
+                    "hour": 19, 
                     "__class__": "datetime", 
                     "month": 5, 
-                    "second": 45, 
-                    "microsecond": 395000, 
-                    "year": 2016, 
-                    "day": 8, 
-                    "minute": 12
+                    "second": 10, 
+                    "microsecond": 961000, 
+                    "year": 2017, 
+                    "day": 3, 
+                    "minute": 9
                 }, 
                 "AvailabilityZones": [
-                    "us-west-2c", 
-                    "us-west-2b", 
-                    "us-west-2a"
+                    "us-east-1d"
                 ], 
                 "HealthCheckType": "EC2", 
                 "NewInstancesProtectedFromScaleIn": false
             }
         ], 
         "ResponseMetadata": {
+            "RetryAttempts": 0, 
             "HTTPStatusCode": 200, 
-            "RequestId": "d80f15e0-1521-11e6-b9d7-7388f3279394"
+            "RequestId": "5c2d0a07-30ec-11e7-a5de-2db2aeef4956", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "5c2d0a07-30ec-11e7-a5de-2db2aeef4956", 
+                "vary": "Accept-Encoding", 
+                "content-length": "2218", 
+                "content-type": "text/xml", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT"
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_3.json b/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_3.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_asg_rename/autoscaling.DescribeAutoScalingGroups_3.json
@@ -0,0 +1,71 @@
+{
+    "status_code": 200, 
+    "data": {
+        "AutoScalingGroups": [
+            {
+                "AutoScalingGroupARN": "arn:aws:autoscaling:us-east-1:644160558196:autoScalingGroup:c3ba9110-56ea-412e-a6ec-aaec45330901:autoScalingGroupName/scot-asg-test", 
+                "TargetGroupARNs": [], 
+                "SuspendedProcesses": [], 
+                "DesiredCapacity": 1, 
+                "Tags": [
+                    {
+                        "ResourceType": "auto-scaling-group", 
+                        "ResourceId": "scot-asg-test", 
+                        "PropagateAtLaunch": true, 
+                        "Value": "ubuntu", 
+                        "Key": "Linux"
+                    }
+                ], 
+                "EnabledMetrics": [], 
+                "LoadBalancerNames": [], 
+                "AutoScalingGroupName": "scot-asg-test", 
+                "DefaultCooldown": 300, 
+                "MinSize": 1, 
+                "Instances": [
+                    {
+                        "ProtectedFromScaleIn": false, 
+                        "AvailabilityZone": "us-east-1d", 
+                        "InstanceId": "i-04ec879cd823dc92a", 
+                        "HealthStatus": "Healthy", 
+                        "LifecycleState": "InService", 
+                        "LaunchConfigurationName": "scot-test2"
+                    }
+                ], 
+                "MaxSize": 1, 
+                "VPCZoneIdentifier": "subnet-3a334610", 
+                "HealthCheckGracePeriod": 300, 
+                "TerminationPolicies": [
+                    "Default"
+                ], 
+                "LaunchConfigurationName": "scot-test2", 
+                "CreatedTime": {
+                    "hour": 19, 
+                    "__class__": "datetime", 
+                    "month": 5, 
+                    "second": 10, 
+                    "microsecond": 961000, 
+                    "year": 2017, 
+                    "day": 3, 
+                    "minute": 9
+                }, 
+                "AvailabilityZones": [
+                    "us-east-1d"
+                ], 
+                "HealthCheckType": "EC2", 
+                "NewInstancesProtectedFromScaleIn": false
+            }
+        ], 
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "5cb1f11c-30ec-11e7-bb00-1547c7e6d37a", 
+            "HTTPHeaders": {
+                "x-amzn-requestid": "5cb1f11c-30ec-11e7-bb00-1547c7e6d37a", 
+                "vary": "Accept-Encoding", 
+                "content-length": "2215", 
+                "content-type": "text/xml", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT"
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/ec2.CreateTags_1.json b/tests/data/placebo/test_asg_rename/ec2.CreateTags_1.json
--- a/tests/data/placebo/test_asg_rename/ec2.CreateTags_1.json
+++ b/tests/data/placebo/test_asg_rename/ec2.CreateTags_1.json
@@ -2,8 +2,16 @@
     "status_code": 200, 
     "data": {
         "ResponseMetadata": {
+            "RetryAttempts": 0, 
             "HTTPStatusCode": 200, 
-            "RequestId": "ffde4c50-c9bb-49c1-9713-cd5c5c7f02ac"
+            "RequestId": "a41b874b-6a35-47b8-88b1-7d49b0709447", 
+            "HTTPHeaders": {
+                "transfer-encoding": "chunked", 
+                "vary": "Accept-Encoding", 
+                "server": "AmazonEC2", 
+                "content-type": "text/xml;charset=UTF-8", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT"
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/ec2.DeleteTags_1.json b/tests/data/placebo/test_asg_rename/ec2.DeleteTags_1.json
--- a/tests/data/placebo/test_asg_rename/ec2.DeleteTags_1.json
+++ b/tests/data/placebo/test_asg_rename/ec2.DeleteTags_1.json
@@ -2,8 +2,16 @@
     "status_code": 200, 
     "data": {
         "ResponseMetadata": {
+            "RetryAttempts": 0, 
             "HTTPStatusCode": 200, 
-            "RequestId": "745c90df-7251-4b5f-a95a-fabd0084830e"
+            "RequestId": "24b97439-153c-4f15-bee0-80fe77c3b379", 
+            "HTTPHeaders": {
+                "transfer-encoding": "chunked", 
+                "vary": "Accept-Encoding", 
+                "server": "AmazonEC2", 
+                "content-type": "text/xml;charset=UTF-8", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT"
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/ec2.DescribeTags_1.json b/tests/data/placebo/test_asg_rename/ec2.DescribeTags_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_asg_rename/ec2.DescribeTags_1.json
@@ -0,0 +1,31 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "b011dc6a-2be6-4d92-9010-019d01156f77", 
+            "HTTPHeaders": {
+                "transfer-encoding": "chunked", 
+                "vary": "Accept-Encoding", 
+                "server": "AmazonEC2", 
+                "content-type": "text/xml;charset=UTF-8", 
+                "date": "Thu, 04 May 2017 17:08:56 GMT"
+            }
+        }, 
+        "Tags": [
+            {
+                "ResourceType": "instance", 
+                "ResourceId": "i-04ec879cd823dc92a", 
+                "Value": "ubuntu", 
+                "Key": "Platform"
+            }, 
+            {
+                "ResourceType": "instance", 
+                "ResourceId": "i-04ec879cd823dc92a", 
+                "Value": "scot-asg-test", 
+                "Key": "aws:autoscaling:groupName"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_asg_rename/ec2.DescribeTags_2.json b/tests/data/placebo/test_asg_rename/ec2.DescribeTags_2.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_asg_rename/ec2.DescribeTags_2.json
@@ -0,0 +1,31 @@
+{
+    "status_code": 200, 
+    "data": {
+        "ResponseMetadata": {
+            "RetryAttempts": 0, 
+            "HTTPStatusCode": 200, 
+            "RequestId": "d382b799-c9fe-4e89-af07-f6ea6009d2ee", 
+            "HTTPHeaders": {
+                "transfer-encoding": "chunked", 
+                "vary": "Accept-Encoding", 
+                "server": "AmazonEC2", 
+                "content-type": "text/xml;charset=UTF-8", 
+                "date": "Thu, 04 May 2017 17:08:57 GMT"
+            }
+        }, 
+        "Tags": [
+            {
+                "ResourceType": "instance", 
+                "ResourceId": "i-04ec879cd823dc92a", 
+                "Value": "ubuntu", 
+                "Key": "Linux"
+            }, 
+            {
+                "ResourceType": "instance", 
+                "ResourceId": "i-04ec879cd823dc92a", 
+                "Value": "scot-asg-test", 
+                "Key": "aws:autoscaling:groupName"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/test_asg.py b/tests/test_asg.py
--- a/tests/test_asg.py
+++ b/tests/test_asg.py
@@ -46,6 +46,16 @@ def test_config_delete(self):
 
 class AutoScalingTest(BaseTest):
 
+    def get_ec2_tags(self, ec2, instance_id):
+        results = ec2.describe_tags(
+            Filters=[
+                {'Name': 'resource-id',
+                 'Values': [instance_id]},
+                {'Name': 'resource-type',
+                 'Values': ['instance']}])['Tags']
+        return {t['Key']: t['Value'] for t in results}
+        
+
     def test_asg_delete(self):
         factory = self.replay_flight_data('test_asg_delete')
         p = self.load_policy({
@@ -148,13 +158,7 @@ def test_asg_tag_and_propagate(self):
         self.assertEqual(tag_map['CustomerId'][0], 'GetSome')
         self.assertEqual(tag_map['CustomerId'][1], True)
 
-        results = ec2.describe_tags(
-            Filters=[
-                {'Name': 'resource-id',
-                 'Values': [instance_id]},
-                {'Name': 'resource-type',
-                 'Values': ['instance']}])['Tags']
-        tag_map = {t['Key']: t['Value'] for t in results}
+        tag_map = self.get_ec2_tags(ec2, instance_id)
         self.assertTrue('CustomerId' in tag_map)
         self.assertFalse('Home' in tag_map)
 
@@ -182,7 +186,7 @@ def test_asg_remove_tag(self):
     def test_asg_mark_for_op(self):
         factory = self.replay_flight_data('test_asg_mark_for_op')
         p = self.load_policy({
-            'name': 'asg-rename-tag',
+            'name': 'asg-mark-for-op',
             'resource': 'asg',
             'filters': [
                 {'tag:Platform': 'ubuntu'}],
@@ -212,9 +216,25 @@ def test_asg_rename_tag(self):
                 {'type': 'rename-tag', 'source': 'Platform', 'dest': 'Linux'}
                 ],
             }, session_factory=factory)
+
+        # Fetch ASG
+        session = factory()
+        client = session.client('autoscaling')
+        result = client.describe_auto_scaling_groups()['AutoScalingGroups'].pop()
+
+        # Fetch instance and make sure it has tags
+        ec2 = session.client('ec2')
+        instance_id = result['Instances'][0]['InstanceId']
+
+        tag_map = self.get_ec2_tags(ec2, instance_id)
+        self.assertTrue('Platform' in tag_map)
+        self.assertFalse('Linux' in tag_map)
+
+        # Run the policy
         resources = p.run()
         self.assertEqual(len(resources), 1)
-        client = factory().client('autoscaling')
+
+        # Validate the ASG tag changed
         result = client.describe_auto_scaling_groups(
             AutoScalingGroupNames=[resources[0]['AutoScalingGroupName']])[
                 'AutoScalingGroups'].pop()
@@ -223,6 +243,11 @@ def test_asg_rename_tag(self):
         self.assertFalse('Platform' in tag_map)
         self.assertTrue('Linux' in tag_map)
 
+        tag_map = self.get_ec2_tags(ec2, instance_id)
+        self.assertFalse('Platform' in tag_map)
+        self.assertTrue('Linux' in tag_map)
+
+
     def test_asg_suspend(self):
         factory = self.replay_flight_data('test_asg_suspend')
         p = self.load_policy({