# Creating n AWS ec2 instances with n different names to each ec2 instance

**URL:** <https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [March 22, 2017, 8:53pm UTC](https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038 "2017-03-22T20:53:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![balubhai555](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@balubhai555](https://forum.ansible.com/u/balubhai555)\
**Post date:** [March 22, 2017, 8:53pm UTC](https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038/1 "2017-03-22T20:53:03Z")

</div>

**Hello Team,**

**I got a requirement to create ‘n’ number of AWS ec2 instances and with different name to each ec2 instance. I have tried different ways but got failures.**

**So will you please suggest me how to create different ec2 instances with different names using “Loops” or any other modules in Ansible.**

**Thank you.**

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 23, 2017, 4:38am UTC](https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038/2 "2017-03-23T04:38:23Z")

</div>

What were those ways exactly, and what were the failures you got with them?

Dick

---

<div class="post-metadata">

**Author:** ![balubhai555](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@balubhai555](https://forum.ansible.com/u/balubhai555)\
**Post date:** [March 28, 2017, 4:20pm UTC](https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038/3 "2017-03-28T16:20:36Z")

</div>

Hello Dick Visser,

I created 4 instances using Ansible EC2 module. I want to give names as A,B,C,D. I want to give those names as " **with\_items:**" loops. So what is the possible ways to modify the below code. I created 4 instances using " **count:4".**

---

<div class="post-metadata">

**Author:** ![Sudhanshu\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@Sudhanshu\_Sharma](https://forum.ansible.com/u/Sudhanshu_Sharma)\
**Post date:** [April 15, 2017, 7:44pm UTC](https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038/4 "2017-04-15T19:44:37Z")

</div>

Hey,

You can use ec2\_tag module, Go thru the link below for detailed explanation -

[http://docs.ansible.com/ansible/ec2\_tag\_module.html](http://docs.ansible.com/ansible/ec2_tag_module.html)

---

<div class="post-metadata">

**Author:** ![balubhai555](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@balubhai555](https://forum.ansible.com/u/balubhai555)\
**Post date:** [April 25, 2017, 3:47pm UTC](https://forum.ansible.com/t/creating-n-aws-ec2-instances-with-n-different-names-to-each-ec2-instance/24038/5 "2017-04-25T15:47:34Z")

</div>

Yes, Thanks for quick answer.

But for ec2\_tag requires " **resource: vol-xxx"**. But when the resource created at the time only resource id generated.  
As i am creating different instances at a time, how can i use the ec2\_tag module with **"resource: "**

Please suggest me.

Thank you in advance.
