Skip to content

Instantly share code, notes, and snippets.

@nleiva
Last active August 24, 2021 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nleiva/1fee0fbd0a2de46cd45aea92325d35a9 to your computer and use it in GitHub Desktop.
Save nleiva/1fee0fbd0a2de46cd45aea92325d35a9 to your computer and use it in GitHub Desktop.
- name: Gather information about all Security Groups in Environment {{ ec2_environment }}
amazon.aws.ec2_group_info:
region: "{{ ec2_region }}"
filters:
vpc-id: "{{ all_vpcs.vpcs[0].vpc_id }}"
register: all_sg
- name: Delete Security Groups in VPC {{ all_vpcs.vpcs[0].vpc_id }} by ID
amazon.aws.ec2_group:
region: "{{ ec2_region }}"
group_id: "{{ item.group_id }}"
state: absent
loop: "{{ all_sg.security_groups }}"
when: item.group_name != "default"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment