# IAM Module does not support tag

**URL:** <https://forum.ansible.com/t/iam-module-does-not-support-tag/31570>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [October 30, 2019, 1:49pm UTC](https://forum.ansible.com/t/iam-module-does-not-support-tag/31570 "2019-10-30T13:49:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkM](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@MarkM](https://forum.ansible.com/u/MarkM)\
**Post date:** [October 30, 2019, 1:49pm UTC](https://forum.ansible.com/t/iam-module-does-not-support-tag/31570/1 "2019-10-30T13:49:28Z")

</div>

Hey guys,

I’m an Ansible noob and was using the AWS IAM module to create users and I noticed this module does not support tagging. Does anyone have any ideas how this can be achieved or if this will be an added feature.

Thanks

---

<div class="post-metadata">

**Author:** ![MarkM](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@MarkM](https://forum.ansible.com/u/MarkM)\
**Post date:** [October 30, 2019, 1:51pm UTC](https://forum.ansible.com/t/iam-module-does-not-support-tag/31570/2 "2019-10-30T13:51:48Z")

</div>

btw, here is the link to the module

[https://docs.ansible.com/ansible/latest/modules/iam\_module.html](https://docs.ansible.com/ansible/latest/modules/iam_module.html)

---

<div class="post-metadata">

**Author:** ![Greg\_Pirker](https://avatars.discourse-cdn.com/v4/letter/g/bbe5ce/32.png) [@Greg\_Pirker](https://forum.ansible.com/u/Greg_Pirker)\
**Post date:** [October 30, 2019, 2:20pm UTC](https://forum.ansible.com/t/iam-module-does-not-support-tag/31570/3 "2019-10-30T14:20:21Z")

</div>

I have had to do something like this to query IAM for information. I attacked my issue by shelling out and running an AWS CLI command (and passing aws\_access\_key, aws\_secret\_key and aws\_region as variables)

export AWS\_ACCESS\_KEY\_ID={{aws\_access\_key}}; export AWS\_SECRET\_ACCESS\_KEY={{aws\_secret\_key}};/bin/aws iam list-roles --query ‘Roles[\*].["RoleName","Arn"]’ --output text --region {{aws\_region}}

In your case, you might do something like this in Ansible by adding two new variables: user\_name and tags (YMMV as I wrote this at the browser; not sure if its syntactically correct):

- name: Set fact for user name:  
set\_fact:  
user\_name: “Some user name”

- name: set iam user tags  
set\_fact:  
iam\_user\_tags:  
user\_tag1: “same\_value”  
user\_tag2: “same\_value”  
user\_tag3: “same\_value”

- name: Set tags for user using AWS CLI  
shell: “export AWS\_ACCESS\_KEY\_ID={{aws\_access\_key}}; export AWS\_SECRET\_ACCESS\_KEY={{aws\_secret\_key}};/bin/aws iam tag-user --user-name {{user\_name}} --tags {{iam\_user\_tags}}”

Honestly, I would probably attack this with a library using python/boto3. If you have time, its pretty easy to build and run.
