@Override
  public void connectToGateway(@Nonnull String providerVpnId, @Nonnull String toGatewayId)
      throws CloudException, InternalException {
    APITrace.begin(provider, "connectVPNToGateway");
    try {
      VPNGateway gateway = getGateway(toGatewayId);
      VPN vpn = getVPN(providerVpnId);

      if (gateway == null) {
        throw new CloudException("No such VPN gateway: " + toGatewayId);
      }
      if (vpn == null) {
        throw new CloudException("No such VPN: " + providerVpnId);
      }
      if (!gateway.getProtocol().equals(vpn.getProtocol())) {
        throw new CloudException(
            "VPN protocol mismatch between VPN and gateway: "
                + vpn.getProtocol()
                + " vs "
                + gateway.getProtocol());
      }
      ProviderContext ctx = provider.getContext();

      if (ctx == null) {
        throw new CloudException("No context was configured");
      }
      Map<String, String> parameters =
          provider.getStandardParameters(provider.getContext(), ELBMethod.CREATE_VPN_CONNECTION);
      EC2Method method;

      parameters.put("Type", getAWSProtocol(vpn.getProtocol()));
      parameters.put("CustomerGatewayId", gateway.getProviderVpnGatewayId());
      parameters.put("VpnGatewayId", vpn.getProviderVpnId());
      method = new EC2Method(provider, parameters);
      try {
        method.invoke();
      } catch (EC2Exception e) {
        logger.error(e.getSummary());
        e.printStackTrace();
        throw new CloudException(e);
      }
    } finally {
      APITrace.end();
    }
  }