Skip to content

Commit

Permalink
ec2_vpc_nat_gateway - changes to no allocate eip address when connect…
Browse files Browse the repository at this point in the history
…ivity_type=private (#1632)

ec2_vpc_nat_gateway - changes to no allocate eip address when connectivity_type=private

SUMMARY

Fixes #1618

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

plugins/modules/ec2_vpc_nat_gateway.py
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
(cherry picked from commit afe9ccb)
  • Loading branch information
taehopark32 authored and hakbailey committed Jul 5, 2023
1 parent 45c4b2b commit c6fa7e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_vpc_nat_gateway - fixes to nat gateway so that when the user creates a private NAT gateway, an Elastic IP address should not be allocated. The module had inncorrectly always allocate elastic IP address when creating private nat gateway (https://github.com/ansible-collections/amazon.aws/pull/1632).
9 changes: 4 additions & 5 deletions plugins/modules/ec2_vpc_nat_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,12 +746,11 @@ def pre_create(client, module, subnet_id, tags, purge_tags, allocation_id=None,
)
return changed, msg, results
else:
changed, msg, allocation_id = (
allocate_eip_address(client, module)
)
if connectivity_type == "public":
changed, msg, allocation_id = allocate_eip_address(client, module)

if not changed:
return changed, msg, dict()
if not changed:
return changed, msg, dict()

elif eip_address or allocation_id:
if eip_address and not allocation_id:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@
- create_ngw.changed
- create_ngw.connectivity_type == 'private'
- '"create_time" in create_ngw'
- '"allocation_id" not in create_ngw.nat_gateway_addresses[0]'

- name: 'set facts: NAT gateway ID'
set_fact:
Expand Down

0 comments on commit c6fa7e1

Please sign in to comment.