UNPKG

3.03 kBJavaScriptView Raw
1'use strict'
2
3const cli = require('heroku-cli-util')
4const co = require('co')
5
6function displayVPNConfigInfo (space, name, config) {
7 cli.styledHeader(`${name} VPN Tunnels`)
8 config.tunnels.forEach((val, i) => {
9 val.tunnel_id = 'Tunnel ' + (i + 1)
10 val.routable_cidr = config.space_cidr_block
11 val.ike_version = config.ike_version
12 })
13
14 cli.table(config.tunnels, {
15 columns: [
16 { key: 'tunnel_id', label: 'VPN Tunnel' },
17 { key: 'customer_ip', label: 'Customer Gateway' },
18 { key: 'ip', label: 'VPN Gateway' },
19 { key: 'pre_shared_key', label: 'Pre-shared Key' },
20 { key: 'routable_cidr', label: 'Routable Subnets' },
21 { key: 'ike_version', label: 'IKE Version' }
22 ]
23 })
24}
25
26function check (val, message) {
27 if (!val) throw new Error(`${message}.\nUSAGE: heroku spaces:vpn:config --space my-space vpn-connection-name`)
28}
29
30function * run (context, heroku) {
31 let space = context.flags.space || context.args.space
32 check(space, 'Space name required')
33
34 let name = context.flags.name || context.args.name
35 check(name, 'VPN connection name required')
36
37 let lib = require('../../lib/vpn-connections')(heroku)
38 let config = yield lib.getVPNConnection(space, name)
39
40 if (context.flags.json) {
41 cli.styledJSON(config)
42 } else {
43 displayVPNConfigInfo(space, name, config)
44 }
45}
46
47module.exports = {
48 topic: 'spaces',
49 command: 'vpn:config',
50 description: 'display the configuration information for VPN',
51 help: `Example:
52
53 $ heroku spaces:vpn:config --space my-space vpn-connection-name
54 === vpn-connection-name VPN Tunnels
55 VPN Tunnel Customer Gateway VPN Gateway Pre-shared Key Routable Subnets IKE Version
56 ────────── ──────────────── ────────────── ────────────── ──────────────── ───────────
57 Tunnel 1 104.196.121.200 35.171.237.136 abcdef12345 10.0.0.0/16 1
58 Tunnel 2 104.196.121.200 52.44.7.216 fedcba54321 10.0.0.0/16 1
59
60You will use the information provided by this command to establish a Private Space VPN Connection.
61
62- You must configure your VPN Gateway to use both Tunnels provided by Heroku
63- The VPN Gateway values are the IP addresses of the Private Space Tunnels
64- The Customer Gateway value is the Public IP of your VPN Gateway
65- The VPN Gateway must use the IKE Version shown and the Pre-shared Keys as the authentication method
66`,
67 hidden: false,
68 needsApp: false,
69 needsAuth: true,
70 args: [{ name: 'name', optional: true, hidden: true }],
71 flags: [
72 { name: 'space', char: 's', hasValue: true, description: 'space the VPN connection belongs to' },
73 { name: 'name', char: 'n', hasValue: true, description: 'name or id of the VPN connection to retrieve config from' },
74 { name: 'json', description: 'output in json format' }
75 ],
76 run: cli.command(co.wrap(run)),
77 displayVPNConfigInfo: displayVPNConfigInfo
78}