# Destroyed ec2 resources with count\_tag and exact count

**URL:** <https://forum.ansible.com/t/destroyed-ec2-resources-with-count-tag-and-exact-count/25277>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 17, 2017, 1:00pm UTC](https://forum.ansible.com/t/destroyed-ec2-resources-with-count-tag-and-exact-count/25277 "2017-08-17T13:00:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_Brooks](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@Bill\_Brooks](https://forum.ansible.com/u/Bill_Brooks)\
**Post date:** [August 17, 2017, 1:00pm UTC](https://forum.ansible.com/t/destroyed-ec2-resources-with-count-tag-and-exact-count/25277/1 "2017-08-17T13:00:43Z")

</div>

I am working with Ansible and just accidentally terminated 4 ec2 instances out of 20+ in AWS and I’m trying to figure out the why as to what was deleted. I have already determined that the code I originally used was wrong, but wish to understand what happened. The quasi code in question was/is:

- name: Create EC2  
ec2:  
key\_name: key  
instance\_type: t2.medium  
image: actual\_amiID  
wait: yes  
region: us-east-1  
vpc\_subnet\_id: actual\_subnetID  
instance\_tags: { “Name”:“vpc03VM01” }  
group\_id: actual\_securitygroupID  
count\_tag: (or count\_tag: 1)  
exact\_count: 1

I’m not 100% sure that count\_tag was empty it may have been 1. 4 instances were destroyed, it tried to destroy a 5th, but it had protection. All of them had some tags, only one of them had the Name tag in question, but two of the other ones were named similarly ( vpc01VM01 / vpc02VM01 ), the other three (including the one that wasn’t destroyed because of protections) were named differently. I want to understand why these instances were terminated and the one that I was trying to create wasn’t created. I was trying to use the count\_tag and exact\_count to be similar in functionality to “state: present.”

---

<div class="post-metadata">

**Author:** ![Bill\_Brooks](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@Bill\_Brooks](https://forum.ansible.com/u/Bill_Brooks)\
**Post date:** [August 17, 2017, 1:40pm UTC](https://forum.ansible.com/t/destroyed-ec2-resources-with-count-tag-and-exact-count/25277/2 "2017-08-17T13:40:52Z")

</div>

I did some further testing and want to confirm that the count\_tag setting I used was:

count\_tag: 1
