| 1 | package VM::EC2::REST::vpn; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use VM::EC2 ''; # important not to import anything! | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | package VM::EC2; # add methods to VM::EC2 | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | VM::EC2::Dispatch->register( | |||||||||||||||||||
| 8 | CreateVpnConnection => 'fetch_one,vpnConnection,VM::EC2::VPC::VpnConnection', | ||||||||||||||||||||
| 9 | CreateVpnConnectionRoute => 'boolean', | ||||||||||||||||||||
| 10 | DeleteVpnConnection => 'boolean', | ||||||||||||||||||||
| 11 | DeleteVpnConnectionRoute => 'boolean', | ||||||||||||||||||||
| 12 | DescribeVpnConnections => 'fetch_items,vpnConnectionSet,VM::EC2::VPC::VpnConnection', | ||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | my $VEP = 'VM::EC2::ParmParser'; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =head1 NAME VM::EC2::REST::vpn | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | use VM::EC2 ':vpc'; | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | =head1 METHODS | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | These methods create and manage the connections of Virtual Private | ||||||||||||||||||||
| 26 | Network (VPN) to Amazon Virtual Private Clouds (VPC). | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | Implemented: | ||||||||||||||||||||
| 29 | CreateVpnConnection | ||||||||||||||||||||
| 30 | CreateVpnConnectionRoute | ||||||||||||||||||||
| 31 | DeleteVpnConnection | ||||||||||||||||||||
| 32 | DeleteVpnConnectionRoute | ||||||||||||||||||||
| 33 | DescribeVpnConnections | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | Unimplemented: | ||||||||||||||||||||
| 36 | (none) | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head2 @vpn_connections = $ec2->describe_vpn_connections(-vpn_connection_id=>\@ids, | ||||||||||||||||||||
| 39 | -filter=>\%filters); | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head2 @vpn_connections = $ec2->describe_vpn_connections(@vpn_connection_ids) | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head2 @vpn_connections = $ec2->describe_vpn_connections(%filters); | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | Gives information about VPN connections | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | Returns a series of VM::EC2::VPC::VpnConnection objects. | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | Optional parameters are: | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | -vpn_connection_id ID of the connection(s) to return information on. | ||||||||||||||||||||
| 52 | This can be a string scalar, or an arrayref. | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | -filter Tags and other filters to apply. | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | The filter argument is a hashreference in which the keys are the | ||||||||||||||||||||
| 57 | filter names, and the values are the match strings. Some filters | ||||||||||||||||||||
| 58 | accept wildcards. | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | There are a number of filters, which are listed in full at | ||||||||||||||||||||
| 61 | http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVpnConnections.html | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | Here is a alpha-sorted list of filter names: | ||||||||||||||||||||
| 64 | customer-gateway-configuration, customer-gateway-id, state, | ||||||||||||||||||||
| 65 | tag-key, tag-value, tag:key, type, vpn-connection-id, | ||||||||||||||||||||
| 66 | vpn-gateway-id | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | sub describe_vpn_connections { | ||||||||||||||||||||
| 71 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
describe_vpn_connections: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 72 | 0 | my %args = $VEP->args(-vpn_connection_id,@_); | |||||||||||||||||||
| 73 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||
| 74 | { | ||||||||||||||||||||
| 75 | list_parm => 'VpnConnectionId', | ||||||||||||||||||||
| 76 | filter_parm => 'Filter', | ||||||||||||||||||||
| 77 | }); | ||||||||||||||||||||
| 78 | 0 | return $self->call('DescribeVpnConnections',@params); | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =head2 $vpn_connection = $ec2->create_vpn_connection(-type =>$type, | ||||||||||||||||||||
| 82 | -customer_gateway_id=>$gtwy_id, | ||||||||||||||||||||
| 83 | -vpn_gateway_id =>$vpn_id) | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | Creates a new VPN connection between an existing virtual private | ||||||||||||||||||||
| 86 | gateway and a VPN customer gateway. The only supported connection | ||||||||||||||||||||
| 87 | type is ipsec.1. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | Required Arguments: | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | -customer_gateway_id -- The ID of the customer gateway | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | -vpn_gateway_id -- The ID of the VPN gateway | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | Optional arguments: | ||||||||||||||||||||
| 96 | -type -- Default is the only currently available option: | ||||||||||||||||||||
| 97 | ipsec.1 (API 2012-06-15) | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | -options_static_routes_only -- Indicates whether or not the VPN connection | ||||||||||||||||||||
| 100 | requires static routes. If you are creating a VPN | ||||||||||||||||||||
| 101 | connection for a device that does not support | ||||||||||||||||||||
| 102 | BGP, you must specify this value as true. | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | -static_routes_only -- Alias for -options_static_routes_only | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | Returns a L<VM::EC2::VPC::VpnConnection> object. | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | sub create_vpn_connection { | ||||||||||||||||||||
| 111 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
create_vpn_connection: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 112 | 0 | my %args = @_; | |||||||||||||||||||
| 113 | 0 | ▶ | $args{-type} ||= 'ipsec.1'; | ||||||||||||||||||
|
Condition0%0/2
$args{"-type"} ||= "ipsec.1"
MC/DC0%0/1
$args{"-type"} ||= "ipsec.1"
$args{"-type"}
Truth table0%0/2
A
A= $args{"-type"}
| |||||||||||||||||||||
| 114 | $args{-vpn_gateway_id} or | ||||||||||||||||||||
| 115 | 0 | ▶ | croak "create_vpn_connection(): -vpn_gateway_id argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 116 | $args{-customer_gateway_id} or | ||||||||||||||||||||
| 117 | 0 | ▶ | croak "create_vpn_connection(): -customer_gateway_id argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 118 | 0 | ▶ | $args{'-options_static_routes_only'} ||= $args{-static_routes_only}; | ||||||||||||||||||
|
Condition0%0/3
$args{"-options_static_routes_only"} ||= $args{"-static_routes_only"}
MC/DC0%0/2
$args{"-options_static_routes_only"} ||= $args{"-static_routes_only"}
$args{"-options_static_routes_only"}
$args{"-static_routes_only"}
Truth table0%0/3
A ||= B
A= $args{"-options_static_routes_only"}B= $args{"-static_routes_only"}
| |||||||||||||||||||||
| 119 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||
| 120 | { | ||||||||||||||||||||
| 121 | boolean_parm => 'Options.StaticRoutesOnly', | ||||||||||||||||||||
| 122 | single_parm => [qw(VpnGatewayId CustomerGatewayId Type)], | ||||||||||||||||||||
| 123 | }); | ||||||||||||||||||||
| 124 | 0 | return $self->call('CreateVpnConnection',@params); | |||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | =head2 $success = $ec2->delete_vpn_connection(-vpn_connection_id=>$vpn_id) | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | =head2 $success = $ec2->delete_vpn_connection($vpn_id) | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | Deletes a VPN connection. Use this if you want to delete a VPC and | ||||||||||||||||||||
| 132 | all its associated components. Another reason to use this operation | ||||||||||||||||||||
| 133 | is if you believe the tunnel credentials for your VPN connection | ||||||||||||||||||||
| 134 | have been compromised. In that situation, you can delete the VPN | ||||||||||||||||||||
| 135 | connection and create a new one that has new keys, without needing | ||||||||||||||||||||
| 136 | to delete the VPC or virtual private gateway. If you create a new | ||||||||||||||||||||
| 137 | VPN connection, you must reconfigure the customer gateway using the | ||||||||||||||||||||
| 138 | new configuration information returned with the new VPN connection ID. | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | Arguments: | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | -vpn_connection_id -- The ID of the VPN connection to delete | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | Returns true on successful deletion. | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | sub delete_vpn_connection { | ||||||||||||||||||||
| 149 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
delete_vpn_connection: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 150 | 0 | my %args = $VEP->args(-vpn_connection_id,@_); | |||||||||||||||||||
| 151 | $args{-vpn_connection_id} or | ||||||||||||||||||||
| 152 | 0 | ▶ | croak "delete_vpn_connection(): -vpn_connection_id argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 153 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||
| 154 | { | ||||||||||||||||||||
| 155 | single_parm => 'VpnConnectionId', | ||||||||||||||||||||
| 156 | }); | ||||||||||||||||||||
| 157 | 0 | return $self->call('DeleteVpnConnection',@params); | |||||||||||||||||||
| 158 | } | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | =head2 $success = $ec2->create_vpn_connection_route(-destination_cidr_block=>$cidr, | ||||||||||||||||||||
| 161 | -vpn_connection_id =>$id) | ||||||||||||||||||||
| 162 | |||||||||||||||||||||
| 163 | Creates a new static route associated with a VPN connection between an existing | ||||||||||||||||||||
| 164 | virtual private gateway and a VPN customer gateway. The static route allows | ||||||||||||||||||||
| 165 | traffic to be routed from the virtual private gateway to the VPN customer | ||||||||||||||||||||
| 166 | gateway. | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | Arguments: | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | -destination_cidr_block -- The CIDR block associated with the local subnet | ||||||||||||||||||||
| 171 | of the customer data center. | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | -vpn_connection_id -- The ID of the VPN connection. | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | Returns true on successsful creation. | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | =cut | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | sub create_vpn_connection_route { | ||||||||||||||||||||
| 180 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
create_vpn_connection_route: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 181 | 0 | my %args = @_; | |||||||||||||||||||
| 182 | $args{-destination_cidr_block} or | ||||||||||||||||||||
| 183 | 0 | ▶ | croak "create_vpn_connection_route(): -destination_cidr_block argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 184 | $args{-vpn_connection_id} or | ||||||||||||||||||||
| 185 | 0 | ▶ | croak "create_vpn_connection_route(): -vpn_connection_id argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 186 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||
| 187 | { | ||||||||||||||||||||
| 188 | single_parm => [qw(DestinationCidrBlock VpnConnectionId)], | ||||||||||||||||||||
| 189 | }); | ||||||||||||||||||||
| 190 | 0 | return $self->call('CreateVpnConnectionRoute',@params); | |||||||||||||||||||
| 191 | } | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | =head2 $success = $ec2->delete_vpn_connection_route(-destination_cidr_block=>$cidr, | ||||||||||||||||||||
| 194 | -vpn_connection_id =>$id) | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | Deletes a static route associated with a VPN connection between an existing | ||||||||||||||||||||
| 197 | virtual private gateway and a VPN customer gateway. The static route allows | ||||||||||||||||||||
| 198 | traffic to be routed from the virtual private gateway to the VPN customer | ||||||||||||||||||||
| 199 | gateway. | ||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | Arguments: | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | -destination_cidr_block -- The CIDR block associated with the local subnet | ||||||||||||||||||||
| 204 | of the customer data center. | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | -vpn_connection_id -- The ID of the VPN connection. | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | Returns true on successsful deletion. | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | sub delete_vpn_connection_route { | ||||||||||||||||||||
| 213 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
delete_vpn_connection_route: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 214 | 0 | my %args = @_; | |||||||||||||||||||
| 215 | $args{-destination_cidr_block} or | ||||||||||||||||||||
| 216 | 0 | ▶ | croak "delete_vpn_connection_route(): -destination_cidr_block argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 217 | $args{-vpn_connection_id} or | ||||||||||||||||||||
| 218 | 0 | ▶ | croak "delete_vpn_connection_route(): -vpn_connection_id argument missing"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 219 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||
| 220 | { | ||||||||||||||||||||
| 221 | single_parm => [qw(DestinationCidrBlock VpnConnectionId)], | ||||||||||||||||||||
| 222 | }); | ||||||||||||||||||||
| 223 | 0 | return $self->call('DeleteVpnConnectionRoute',@params); | |||||||||||||||||||
| 224 | } | ||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | =head1 SEE ALSO | ||||||||||||||||||||
| 227 | |||||||||||||||||||||
| 228 | L<VM::EC2> | ||||||||||||||||||||
| 229 | |||||||||||||||||||||
| 230 | =head1 AUTHOR | ||||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>. | ||||||||||||||||||||
| 233 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||||||||||||||||||||
| 234 | |||||||||||||||||||||
| 235 | Copyright (c) 2012 Loyalty Methods, Inc. | ||||||||||||||||||||
| 236 | Copyright (c) 2012 Ontario Institute for Cancer Research | ||||||||||||||||||||
| 237 | |||||||||||||||||||||
| 238 | This package and its accompanying libraries is free software; you can | ||||||||||||||||||||
| 239 | redistribute it and/or modify it under the terms of the GPL (either | ||||||||||||||||||||
| 240 | version 1, or at your option, any later version) or the Artistic | ||||||||||||||||||||
| 241 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||||||||||||||||||||
| 242 | please see DISCLAIMER.txt for disclaimers of warranty. | ||||||||||||||||||||
| 243 | |||||||||||||||||||||
| 244 | =cut | ||||||||||||||||||||
| 245 | |||||||||||||||||||||
| 246 | |||||||||||||||||||||
| 247 | 1 | 1; | |||||||||||||||||||