Skip to content

Commit

Permalink
update ec2_transit_gateway to use module_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar242 committed Oct 10, 2024
1 parent 0c6e997 commit 7012f35
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/modules/ec2_transit_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AnsibleEC2Error
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import create_ec2_transit_gateway
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import delete_ec2_transit_gateway
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_ec2_transit_gateways
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
Expand Down Expand Up @@ -355,8 +357,10 @@ def create_tgw(self, description: str) -> Dict[str, Any]:
options["DnsSupport"] = self.enable_option_flag(self._module.params.get("dns_support"))
options["MulticastSupport"] = self.enable_option_flag(self._module.params.get("multicast_support"))

params = {"Description": description, "Options": options}

try:
response = self._connection.create_transit_gateway(Description=description, Options=options)
response = create_ec2_transit_gateway(self._connection, **params)
except AnsibleEC2Error as e:
self._module.fail_json_aws(e)

Expand All @@ -379,9 +383,9 @@ def delete_tgw(self, tgw_id: str) -> Dict[str, Any]:
"""
wait = self._module.params.get("wait")
wait_timeout = self._module.params.get("wait_timeout")

params = {"TransitGatewayId": tgw_id}
try:
response = self._connection.delete_transit_gateway(TransitGatewayId=tgw_id)
response = delete_ec2_transit_gateway(self._connection, **params)
except AnsibleEC2Error as e:
self._module.fail_json_aws(e)

Expand Down

0 comments on commit 7012f35

Please sign in to comment.