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

ec2_vpc_igw should be able to remove detached internet gateway #1669

Closed
1 task done
branic opened this issue Jul 27, 2023 · 4 comments · Fixed by #1786
Closed
1 task done

ec2_vpc_igw should be able to remove detached internet gateway #1669

branic opened this issue Jul 27, 2023 · 4 comments · Fixed by #1786
Labels
feature This issue/PR relates to a feature request integration tests/integration module module plugins plugin (any type) tests tests waiting_on_contributor Needs help. Feel free to engage to get things unblocked

Comments

@branic
Copy link
Contributor

branic commented Jul 27, 2023

Summary

I am trying to delete an internet gateway that is in a detached state.

The way the ec2_vpc_igw module currently works a vpc_id has to be supplied and the igw is deleted based on looking up the igw by the vpc_id, then it is detached from the VPC and finally deleted. This makes it such that igws in a detached state cannot be deleted.

It would be useful to be able to supply an internet_gateway_id and have the module detach it from the VPC if needed and then delete it.

Issue Type

Feature Idea

Component Name

ec2_vpc_igw

Additional Information

---
- name: Testing playbook
  hosts: localhost
  gather_facts: false

  tasks:
    - name: Gather internet gateway info
      amazon.aws.ec2_vpc_route_table_info:
        profile: <<REDACTED>>
        region: us-east-2
      register: aws_igws

    - name: Remove internet gateways
      amazon.aws.ec2_vpc_igw:
        profile: <<REDACTED>>
        region: us-east-2
        internet_gateway_id: "{{ igw['internet_gateway_id'] }}"
        state: absent
      loop: "{{ aws_igws['internet_gateways'] }}"

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request integration tests/integration module module plugins plugin (any type) tests tests labels Jul 27, 2023
@alinabuzachis
Copy link
Collaborator

@branic Thank you for bringing this up. Will you be willing to work on a patch to fix this and open a pull request?

@alinabuzachis alinabuzachis added waiting_on_contributor Needs help. Feel free to engage to get things unblocked and removed needs_triage labels Jul 31, 2023
@branic
Copy link
Contributor Author

branic commented Jul 31, 2023

@alinabuzachis Yes, I'll work on a patch and open a PR.

branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 3, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 16, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 16, 2023
branic added a commit to branic/amazon.aws that referenced this issue Oct 26, 2023
tremble pushed a commit to branic/amazon.aws that referenced this issue Oct 31, 2023
softwarefactory-project-zuul bot pushed a commit that referenced this issue Oct 31, 2023
Add ability to remove detached internet gateway

SUMMARY

Introduces the ability to remove an internet gateway that is not attached to a VPC. To remove an internet gateway either the ID of the internet gateway or the ID of the attached VPC can be supplied. It is also possible to supply both IDs. If both IDs are supplied then a failure will be generated if the attached VPC ID does not match the user supplied VPC.

Fixes #1669
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_vpc_igw
ADDITIONAL INFORMATION



I wasn't able to add a test for removing an internet gateway that is detached as the module currently doesn't have a way to create a detached internet gateway. I plan on opening a follow-up PR for that use case and will add an appropriate removal test in that PR.

Reviewed-by: Mark Chappell
Reviewed-by: Brant Evans <[email protected]>
Reviewed-by: Brian A. Teller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request integration tests/integration module module plugins plugin (any type) tests tests waiting_on_contributor Needs help. Feel free to engage to get things unblocked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants