From c94f49cc1ed4dee9bcf96bb509ee0489f72ce200 Mon Sep 17 00:00:00 2001 From: Lars Fronius Date: Tue, 15 Mar 2016 16:50:57 +0100 Subject: [PATCH] Only count user-assigned tags for TagLimitExceeded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/allocation-tag-restrictions.html "Reserved prefix—aws: AWS-assigned tag names and values are automatically assigned the aws: prefix, which the user cannot assign. AWS-assigned tag names do not count towards the tag limit of 10. User-assigned tag names have the prefix user: in the Cost Allocation Report." --- moto/ec2/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index db2b71bcb..9707eb973 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -774,9 +774,9 @@ class TagBackend(object): raise InvalidParameterValueErrorTagNull() for resource_id in resource_ids: if resource_id in self.tags: - if len(self.tags[resource_id]) + len(tags) > 10: + if len(self.tags[resource_id]) + len([tag for tag in tags if not tag.startswith("aws:")]) > 10: raise TagLimitExceeded() - elif len(tags) > 10: + elif len([tag for tag in tags if not tag.startswith("aws:")]) > 10: raise TagLimitExceeded() for resource_id in resource_ids: for tag in tags: