Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Molecule - ec2 delete other instance present in a VPC #136

Open
shubham823 opened this issue Apr 24, 2023 · 3 comments
Open

Molecule - ec2 delete other instance present in a VPC #136

shubham823 opened this issue Apr 24, 2023 · 3 comments
Labels
bug Something isn't working ec2 Amazon EC2

Comments

@shubham823
Copy link

Molecule instance before spinning up a instance it deletes all the other instances in present in a vpc which is a major bug.

@shubham823
Copy link
Author

- name: Destroy ephemeral EC2 instances
  ec2_instance:
    profile: "{{ item.aws_profile | default(omit) }}"
    region: "{{ item.region | default(omit) }}"
    instance_ids: "{{ instance_config | map(attribute='instance_ids') | flatten }}"
    state: absent
  loop: "{{ platforms }}"
  loop_control:
    label: "{{ item.name }}"
  register: ec2_instances_async
  async: 7200
  poll: 0

it can be fixed by adding one line.

- name: Destroy ephemeral EC2 instances
  ec2_instance:
    profile: "{{ item.aws_profile | default(omit) }}"
    region: "{{ item.region | default(omit) }}"
    instance_ids: "{{ instance_config | map(attribute='instance_ids') | flatten }}"
    state: absent
  loop: "{{ platforms }}"
  loop_control:
    label: "{{ item.name }}"

code start

  when: instannce_config != '{}'

code end

  register: ec2_instances_async
  async: 7200
  poll: 0

@apatard
Copy link
Member

apatard commented Apr 26, 2023

Looks like a dup of #121 ?

@danielpodwysocki
Copy link
Contributor

Can this be closed off since it looks like it's been fixed already?

#170

I wandered into here because I ran into it as well, but my destroy playbooks just needed updating

A fix for anyone still encountering it would be to update the plugin and delete -> re-generate the destroy scenarios under molecule/ in their role's directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ec2 Amazon EC2
Projects
None yet
Development

No branches or pull requests

3 participants