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

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.

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

Dick

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".

Hey,

You can use ec2_tag module, Go thru the link below for detailed explanation -

http://docs.ansible.com/ansible/ec2_tag_module.html

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.