title: Ansible - EC2 create new and remove tag
body: <p>I've more than 100 running instances</p>
  
  <p>Example I have 10 running instances with tag name <code>dev-redis-slave</code>. And now I want to create new tag -> tag <code>ServiceName: redis-slave</code> and tag <code>ServiceGroup: redis</code></p>
  
  <p>First of all, I try following this guide: <a href="https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/" rel="nofollow noreferrer">https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/</a></p>
  
  <p>Then I try to excecute <code>ec2.py --list | grep redis</code>. Then the output is: <code>tag_Name_dev_redis_slave</code>. Also I try to ping: <code>ansible -m ping tag_Name_dev_redis_slave</code> and success.</p>
  
  <p>Next I want to create new tag for <code>dev-redis-slave</code> using ansible.,
  I create yaml file like this (playbook.yaml).</p>
  
  <pre><code>- hosts: localhost
    gather_facts: yes
    tasks:
    - name: Adding tags
      ec2_tag:
        resource: tag_Name_dev_redis_slave
        region: xxx
        state: present
        tags:
          ServiceGroup: redis
          ServiceName: redis-slave
  </code></pre>
  
  <p>I run <code>ansible-playbook playbook.yaml</code> But It give an error.</p>
  
  <pre><code>An exception occurred during task execution. To see the full traceback, use -vvv. The error was: &lt;Response&gt;&lt;Errors&gt;&lt;Error&gt;&lt;Code&gt;InvalidID&lt;/Code&gt;&lt;Message&gt;The ID 'tag_Name_dev_redis_slave' is not valid&lt;/Message&gt;&lt;/Error&gt;&lt;/Errors&gt;&lt;RequestID&gt;de51df48-df26-4312-8d03-4c8ca2b993bf&lt;/RequestID&gt;&lt;/Response&gt;
  fatal: [localhost]: FAILED! =&gt; {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/5b/hhh0h2fx2cxf7_24dmn05ht00000gq/T/ansible_460t6taz/ansible_module_ec2_tag.py\", line 183, in &lt;module&gt;\n    main()\n  File \"/var/folders/5b/hhh0h2fx2cxf7_24dmn05ht00000gq/T/ansible_460t6taz/ansible_module_ec2_tag.py\", line 160, in main\n    ec2.create_tags(resource, dictadd)\n  File \"/Users/fourirakbar/Documents/ansible/venv/lib/python3.6/site-packages/boto/ec2/connection.py\", line 4219, in create_tags\n    return self.get_status('CreateTags', params, verb='POST')\n  File \"/Users/fourirakbar/Documents/ansible/venv/lib/python3.6/site-packages/boto/connection.py\", line 1227, in get_status\n    raise self.ResponseError(response.status, response.reason, body)\nboto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;Response&gt;&lt;Errors&gt;&lt;Error&gt;&lt;Code&gt;InvalidID&lt;/Code&gt;&lt;Message&gt;The ID 'tag_Name_dev_redis_slave' is not valid&lt;/Message&gt;&lt;/Error&gt;&lt;/Errors&gt;&lt;RequestID&gt;de51df48-df26-4312-8d03-4c8ca2b993bf&lt;/RequestID&gt;&lt;/Response&gt;\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
  </code></pre>
  
  <p>I also try to follow this: <a href="http://ansible-manual.readthedocs.io/en/latest/ec2_tag_module.html#examples" rel="nofollow noreferrer">http://ansible-manual.readthedocs.io/en/latest/ec2_tag_module.html#examples</a> . But also error.</p>
  
  <p>how to fix it?</p>