Repository: getmoto/moto

Issue:
Support AutoScaling delete_tags
As IMPLEMENTATION_COVERAGE.md indicates, AutoScaling **delete_tags** is not currently supported. I would like to help add it, and am creating this issue to associate a PR.


Discussion:

Resolving patch:
diff --git a/moto/autoscaling/models.py b/moto/autoscaling/models.py
--- a/moto/autoscaling/models.py
+++ b/moto/autoscaling/models.py
@@ -992,6 +992,14 @@ def create_or_update_tags(self, tags):
 
             group.tags = new_tags
 
+    def delete_tags(self, tags):
+        for tag_to_delete in tags:
+            group_name = tag_to_delete["resource_id"]
+            key_to_delete = tag_to_delete["key"]
+            group = self.autoscaling_groups[group_name]
+            old_tags = group.tags
+            group.tags = [x for x in old_tags if x["key"] != key_to_delete]
+
     def attach_load_balancers(self, group_name, load_balancer_names):
         group = self.autoscaling_groups[group_name]
         group.load_balancers.extend(
diff --git a/moto/autoscaling/responses.py b/moto/autoscaling/responses.py
--- a/moto/autoscaling/responses.py
+++ b/moto/autoscaling/responses.py
@@ -233,6 +233,13 @@ def create_or_update_tags(self):
         template = self.response_template(UPDATE_AUTOSCALING_GROUP_TEMPLATE)
         return template.render()
 
+    def delete_tags(self):
+        tags = self._get_list_prefix("Tags.member")
+
+        self.autoscaling_backend.delete_tags(tags)
+        template = self.response_template(UPDATE_AUTOSCALING_GROUP_TEMPLATE)
+        return template.render()
+
     def describe_auto_scaling_instances(self):
         instance_states = self.autoscaling_backend.describe_auto_scaling_instances(
             instance_ids=self._get_multi_param("InstanceIds.member")


Test patch:
diff --git a/tests/test_autoscaling/test_autoscaling.py b/tests/test_autoscaling/test_autoscaling.py
--- a/tests/test_autoscaling/test_autoscaling.py
+++ b/tests/test_autoscaling/test_autoscaling.py
@@ -2640,3 +2640,55 @@ def test_terminate_instance_in_auto_scaling_group_no_decrement():
     original_instance_id.shouldnt.be.within(
         [x["InstanceId"] for x in response["LoadBalancerDescriptions"][0]["Instances"]]
     )
+
+
+@mock_autoscaling
+@mock_ec2
+def test_delete_tags_by_key():
+    mocked_networking = setup_networking()
+    client = boto3.client("autoscaling", region_name="us-east-1")
+    client.create_launch_configuration(
+        LaunchConfigurationName="TestLC",
+        ImageId=EXAMPLE_AMI_ID,
+        InstanceType="t2.medium",
+    )
+    tag_to_delete = {
+        "ResourceId": "tag_test_asg",
+        "ResourceType": "auto-scaling-group",
+        "PropagateAtLaunch": True,
+        "Key": "TestDeleteTagKey1",
+        "Value": "TestTagValue1",
+    }
+    tag_to_keep = {
+        "ResourceId": "tag_test_asg",
+        "ResourceType": "auto-scaling-group",
+        "PropagateAtLaunch": True,
+        "Key": "TestTagKey1",
+        "Value": "TestTagValue1",
+    }
+    client.create_auto_scaling_group(
+        AutoScalingGroupName="tag_test_asg",
+        MinSize=1,
+        MaxSize=2,
+        LaunchConfigurationName="TestLC",
+        Tags=[tag_to_delete, tag_to_keep],
+        VPCZoneIdentifier=mocked_networking["subnet1"],
+    )
+
+    client.delete_tags(
+        Tags=[
+            {
+                "ResourceId": "tag_test_asg",
+                "ResourceType": "auto-scaling-group",
+                "PropagateAtLaunch": True,
+                "Key": "TestDeleteTagKey1",
+            }
+        ]
+    )
+    response = client.describe_auto_scaling_groups(
+        AutoScalingGroupNames=["tag_test_asg"]
+    )
+    group = response["AutoScalingGroups"][0]
+    tags = group["Tags"]
+    tags.should.contain(tag_to_keep)
+    tags.should_not.contain(tag_to_delete)