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

Add utils for ec2_vpc_vgw_* #2331

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- module_utils/ec2 - add utils for the ec2_vpc_vgw_* modules (https://github.com/ansible-collections/amazon.aws/pull/2331).
49 changes: 49 additions & 0 deletions plugins/module_utils/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,55 @@ def create_dhcp_options(
return client.create_dhcp_options(**params)["DhcpOptions"]


# EC2 VPC VPN Gateways
class EC2VpcVpnGatewaysErrorHandler(AWSErrorHandler):
_CUSTOM_EXCEPTION = AnsibleEC2Error

@classmethod
def _is_missing(cls):
return is_boto3_error_code(["InvalidVpnGatewayID.NotFound", "InvalidVpnGatewayState"])


@EC2VpcVpnGatewaysErrorHandler.list_error_handler("describe vpc vpn gateways", [])
@AWSRetry.jittered_backoff()
def describe_vpc_vpn_gateways(
client, **params: Dict[str, Union[List[str], int, List[Dict[str, Union[str, List[str]]]]]]
) -> List[Dict[str, Any]]:
return client.describe_vpn_gateways(**params)


@EC2VpcVpnGatewaysErrorHandler.list_error_handler("create vpc vpn gateway", [])
@AWSRetry.jittered_backoff()
def create_vpc_vpn_gateway(
client, **params: Dict[str, Union[List[str], int, List[Dict[str, Union[str, List[str]]]]]]
) -> List[Dict[str, Any]]:
return client.create_vpn_gateway(**params)


@EC2VpcVpnGatewaysErrorHandler.list_error_handler("delete vpc vpn gateway", [])
@AWSRetry.jittered_backoff()
def delete_vpc_vpn_gateway(
client, **params: Dict[str, Union[List[str], int, List[Dict[str, Union[str, List[str]]]]]]
) -> List[Dict[str, Any]]:
return client.delete_vpn_gateway(**params)


@EC2VpcVpnGatewaysErrorHandler.list_error_handler("attach vpc vpn gateway", [])
@AWSRetry.jittered_backoff()
def attach_vpc_vpn_gateway(
client, **params: Dict[str, Union[List[str], int, List[Dict[str, Union[str, List[str]]]]]]
) -> List[Dict[str, Any]]:
return client.attach_vpn_gateway(**params)


@EC2VpcVpnGatewaysErrorHandler.list_error_handler("detach vpc vpn gateway", [])
@AWSRetry.jittered_backoff()
def detach_vpc_vpn_gateway(
client, **params: Dict[str, Union[List[str], int, List[Dict[str, Union[str, List[str]]]]]]
) -> List[Dict[str, Any]]:
return client.detach_vpn_gateway(**params)


# EC2 Volumes
class EC2VolumeErrorHandler(AWSErrorHandler):
_CUSTOM_EXCEPTION = AnsibleEC2Error
Expand Down
Loading