Reputation: 189
I am trying to create a new tag called Name
and value hostname apphostname
for an Amazon EC2 instance.
Below is my code, and it is failing with this error message:
>>> ec2.create_tags(["i-1923943832310"], {"name": "apphostname"})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/botocore/client.py", line 157, in _api_call
"%s() only accepts keyword arguments." % py_operation_name)
TypeError: create_tags() only accepts keyword arguments.
>>>
Upvotes: 9
Views: 19057
Reputation: 52393
See Create Tags. It expects key value arguments. Tags
is a list of dictionaries. You can create more than one tag if you want.
ec2.create_tags(Resources=['i-1923943832310'], Tags=[{'Key':'name', 'Value':'apphostname'}])
Upvotes: 20