Destroyed ec2 resources with count_tag and exact count

21 views
Skip to first unread message

Bill Brooks

unread,
Aug 17, 2017, 9:00:44 AM8/17/17
to Ansible Project
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."

Bill Brooks

unread,
Aug 17, 2017, 9:40:52 AM8/17/17
to Ansible Project
I did some further testing and want to confirm that the count_tag setting I used was: 

count_tag: 1
Reply all
Reply to author
Forward
0 new messages