Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Oct 14, 2024
1 parent 3b89626 commit 85ba284
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions plugins/module_utils/transitgateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
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_vpc_attachment
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import delete_vpc_attachment
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import create_transit_gateway_vpc_attachment
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import delete_transit_gateway_vpc_attachment
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_subnets
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_vpc_attachments
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_transit_gateway_vpc_attachments
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import modify_vpc_attachment
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import modify_transit_gateway_vpc_attachment
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications
from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list
Expand Down Expand Up @@ -98,7 +98,7 @@ def find_existing_attachment(
params["Filters"] = ansible_dict_to_boto3_filter_list(filters)

try:
attachments = describe_vpc_attachments(client, **params)
attachments = describe_transit_gateway_vpc_attachments(client, **params)
except AnsibleEC2Error as e:
module.fail_json_aws_error(e)

Expand Down Expand Up @@ -146,7 +146,7 @@ def create_attachment(self, params: Dict[str, Any]) -> str:
params["TagSpecifications"] = boto3_tag_specifications(tags, types=["transit-gateway-attachment"])

try:
response = create_vpc_attachment(self.client, **params)
response = create_transit_gateway_vpc_attachment(self.client, **params)
except AnsibleEC2Error as e:
self.module.fail_json_aws_error(e)

Expand All @@ -161,9 +161,8 @@ def delete_attachment(self) -> bool:
return False

if not self.module.check_mode:
params = dict(TransitGatewayAttachmentId=self.attachment_id)
try:
delete_vpc_attachment(self.client, **params)
delete_transit_gateway_vpc_attachment(self.client, self.attachment_id)
except AnsibleEC2Error as e:
self.module.fail_json_aws_error(e)

Expand Down Expand Up @@ -400,7 +399,7 @@ def apply_configuration(self):

if not self.module.check_mode:
try:
modify_vpc_attachment(self.client, **updates)
modify_transit_gateway_vpc_attachment(self.client, **updates)
except AnsibleEC2Error as e:
self.module.fail_json_aws_error(e)
return True
Expand Down

0 comments on commit 85ba284

Please sign in to comment.