Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Oct 4, 2024
1 parent 8a87a58 commit f426d87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions plugins/modules/ec2_vpc_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,13 @@ def find_connection_response(module, connections: Optional[List[Dict[str, Any]]]
returns None if the connection does not exist, raise an error if multiple matches are found."""

# Found no connections
if not connections or "VpnConnections" not in connections:
if not connections:
return None

# Too many results
elif connections and len(connections["VpnConnections"]) > 1:
elif connections and len(connections) > 1:
viable = []
for each in connections["VpnConnections"]:
for each in connections:
# deleted connections are not modifiable
if each["State"] not in ("deleted", "deleting"):
viable.append(each)
Expand All @@ -605,10 +605,10 @@ def find_connection_response(module, connections: Optional[List[Dict[str, Any]]]
)

# Found unique match
elif connections and len(connections["VpnConnections"]) == 1:
elif connections and len(connections) == 1:
# deleted connections are not modifiable
if connections["VpnConnections"][0]["State"] not in ("deleted", "deleting"):
return connections["VpnConnections"][0]
if connections[0]["State"] not in ("deleted", "deleting"):
return connections[0]


def create_connection(
Expand Down Expand Up @@ -660,7 +660,7 @@ def create_connection(
try:
vpn = create_vpn_connection(client, **vpn_connection_params)
client.get_waiter("vpn_connection_available").wait(
VpnConnectionIds=[vpn["VpnConnection"]["VpnConnectionId"]],
VpnConnectionIds=[vpn["VpnConnectionId"]],
WaiterConfig={"Delay": delay, "MaxAttempts": max_attempts},
)
except WaiterError as e:
Expand All @@ -670,7 +670,7 @@ def create_connection(
except AnsibleEC2Error as e:
module.fail_json_aws(e, msg="Failed to create VPN connection")

return vpn["VpnConnection"]
return vpn


def delete_connection(client, module: AnsibleAWSModule, vpn_connection_id: str) -> NoReturn:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_vpc_vpn_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def list_vpn_connections(client, module: AnsibleAWSModule) -> NoReturn:
except AnsibleEC2Error as e:
module.fail_json_aws(e, msg="Could not describe customer gateways")

snaked_vpn_connections = [camel_dict_to_snake_dict(vpn_connection) for vpn_connection in result["VpnConnections"]]
snaked_vpn_connections = [camel_dict_to_snake_dict(vpn_connection) for vpn_connection in result]
if snaked_vpn_connections:
for vpn_connection in snaked_vpn_connections:
vpn_connection["tags"] = boto3_tag_list_to_ansible_dict(vpn_connection.get("tags", []))
Expand Down

0 comments on commit f426d87

Please sign in to comment.