govuk-connect 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/govuk_connect/cli.rb +68 -1
- data/lib/govuk_connect/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1833e17a6b23f0f56d7dd8c7777df90aef85a88edc4d1d291392a4ae8d674e
|
4
|
+
data.tar.gz: db810372f0a69022dfdd976fce2a5844b61595795badcba4e62ed52ca9e4ad4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 108c4c799b5a9de65253a797dac03572c0b49f374bfd7c7bf9b3d2603e24b30fad7310d0b1ed5f7663292b6213dfbd87cda128855280f7017e8aeb6906e7910d
|
7
|
+
data.tar.gz: e53d6fa5bd5535b864c350bd021a5b5dd4fbfd3a7935df4b7cef4e5658750d02bc24b9c727324b6e92ff3d6989a99cf00425be4f3a6efee73ae786c2ede2d9e3
|
data/lib/govuk_connect/cli.rb
CHANGED
@@ -29,6 +29,8 @@ class GovukConnect::CLI
|
|
29
29
|
gds govuk connect app-dbconsole -e integration whitehall_backend/whitehall
|
30
30
|
|
31
31
|
gds govuk connect rabbitmq -e staging aws/rabbitmq
|
32
|
+
|
33
|
+
gds govuk connect amazonmq -e integration
|
32
34
|
EXAMPLES
|
33
35
|
|
34
36
|
MACHINE_TARGET_DESCRIPTION = <<-DOCS.freeze
|
@@ -73,9 +75,11 @@ class GovukConnect::CLI
|
|
73
75
|
"app-console" => "Launch a console for an application. For example, a rails console when connecting to a Rails application.",
|
74
76
|
"app-dbconsole" => "Launch a console for the database for an application.",
|
75
77
|
"rabbitmq" => "Setup port forwarding to the RabbitMQ admin interface.",
|
78
|
+
"amazonmq" => "Setup port forwarding to the AmazonMQ admin interface.",
|
76
79
|
}.freeze
|
77
80
|
|
78
81
|
RABBITMQ_PORT = 15_672
|
82
|
+
AMAZONMQ_PORT = 443
|
79
83
|
|
80
84
|
JUMPBOXES = {
|
81
85
|
test: {
|
@@ -113,6 +117,10 @@ class GovukConnect::CLI
|
|
113
117
|
info "Check this is correct, and if it isn't, set the `USER` environment variable to the correct username."
|
114
118
|
end
|
115
119
|
|
120
|
+
def print_vpn_help_info
|
121
|
+
info "You may also wish to check that you are connected to the VPN, as attempting to SSH into an instance when NOT on the VPN can result in an operation timed out error"
|
122
|
+
end
|
123
|
+
|
116
124
|
# From Rosetta Code: https://rosettacode.org/wiki/Levenshtein_distance#Ruby
|
117
125
|
def levenshtein_distance(string1, string2)
|
118
126
|
string1 = string1.downcase
|
@@ -289,6 +297,8 @@ class GovukConnect::CLI
|
|
289
297
|
error "\nerror: command failed: #{command}"
|
290
298
|
print_empty_line
|
291
299
|
print_ssh_username_configuration_help
|
300
|
+
print_empty_line
|
301
|
+
print_vpn_help_info
|
292
302
|
exit 1
|
293
303
|
end
|
294
304
|
|
@@ -572,6 +582,40 @@ class GovukConnect::CLI
|
|
572
582
|
exec(*ssh_command)
|
573
583
|
end
|
574
584
|
|
585
|
+
def remote_port_forward(
|
586
|
+
target,
|
587
|
+
environment,
|
588
|
+
port_forward,
|
589
|
+
additional_arguments: []
|
590
|
+
)
|
591
|
+
log "debug: remote port-forward to #{target} in #{environment}"
|
592
|
+
|
593
|
+
target, hosting = ssh_target(target, environment)
|
594
|
+
|
595
|
+
localhost_port = random_free_port
|
596
|
+
|
597
|
+
ssh_command = [
|
598
|
+
"ssh",
|
599
|
+
*ssh_identity_arguments,
|
600
|
+
"-N",
|
601
|
+
"-L",
|
602
|
+
"#{localhost_port}:#{target}:#{port_forward}",
|
603
|
+
user_at_host(
|
604
|
+
ssh_username,
|
605
|
+
jumpbox_for_environment_and_hosting(environment, hosting),
|
606
|
+
),
|
607
|
+
]
|
608
|
+
|
609
|
+
info "Port forwarding setup, access:\n\n https://127.0.0.1:#{localhost_port}/\n\n"
|
610
|
+
info "(ignore any warnings about certificate mis-match - this is expected and OK)"
|
611
|
+
|
612
|
+
ssh_command += additional_arguments
|
613
|
+
|
614
|
+
info "\n#{bold('Running command:')} #{ssh_command.join(' ')}\n\n"
|
615
|
+
|
616
|
+
exec(*ssh_command)
|
617
|
+
end
|
618
|
+
|
575
619
|
def scp(
|
576
620
|
target,
|
577
621
|
environment,
|
@@ -624,6 +668,10 @@ class GovukConnect::CLI
|
|
624
668
|
"cd #{directory} && rake eyaml:decrypt_value[#{environment},govuk_rabbitmq::root_password]"
|
625
669
|
end
|
626
670
|
|
671
|
+
def amazonmq_root_password_command(environment)
|
672
|
+
"sops data/app-amazonmq/#{environment}/common.secret.tfvars"
|
673
|
+
end
|
674
|
+
|
627
675
|
def hosting_and_environment_from_url(url)
|
628
676
|
uri = URI(url)
|
629
677
|
|
@@ -788,7 +836,7 @@ class GovukConnect::CLI
|
|
788
836
|
# Split something like aws/backend:2 in to :aws, 'backend', 2
|
789
837
|
hosting, name, number = parse_hosting_name_and_number(target)
|
790
838
|
|
791
|
-
if name.end_with? ".internal"
|
839
|
+
if name.end_with?(".internal") || name.end_with?(".govuk-internal.digital")
|
792
840
|
target = name
|
793
841
|
hosting = :aws
|
794
842
|
else
|
@@ -906,6 +954,25 @@ class GovukConnect::CLI
|
|
906
954
|
)
|
907
955
|
end,
|
908
956
|
|
957
|
+
"amazonmq" => proc do |target, environment, args, extra_args, _options|
|
958
|
+
check_for_additional_arguments("amazonmq", args)
|
959
|
+
check_for_additional_arguments("amazonmq", extra_args)
|
960
|
+
|
961
|
+
target ||= "publishingmq.#{environment}.govuk-internal.digital"
|
962
|
+
|
963
|
+
info "You'll need to login as the RabbitMQ #{bold('root')} user."
|
964
|
+
info "Get the password from govuk-aws-data, for example:\n\n"
|
965
|
+
info " # from the root directory of govuk-aws-data repository\n\n"
|
966
|
+
info " #{bold(amazonmq_root_password_command(environment))}"
|
967
|
+
print_empty_line
|
968
|
+
|
969
|
+
remote_port_forward(
|
970
|
+
target,
|
971
|
+
environment,
|
972
|
+
AMAZONMQ_PORT,
|
973
|
+
)
|
974
|
+
end,
|
975
|
+
|
909
976
|
"ssh" => proc do |target, environment, args, extra_args, options|
|
910
977
|
check_for_target(target)
|
911
978
|
target = target_from_options(target, options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 4.
|
61
|
+
version: 4.9.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 4.
|
68
|
+
version: 4.9.0
|
69
69
|
description: Command line tool to connect to GOV.UK infrastructure
|
70
70
|
email:
|
71
71
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.4.5
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: govuk-connect command line tool
|