train-awsssm 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/train-awsssm/connection.rb +23 -3
- data/lib/train-awsssm/transport.rb +1 -0
- data/lib/train-awsssm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84b93f6b8c8e42c234b406aaeede3112f9eb8a5d2bb8f25973ca6bac555ebe91
|
4
|
+
data.tar.gz: fb7af1a14b231cffdd3de53b52912fc06cd820c683783f4ed2c45415eef157fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39739ed9e732f26a55ac2a748b932e35c74f94aaa3de0a026d25563ef11b376277ed261bfe1a3bb7e2da3fc0260bf3e8f37b619b530a78ee0ba630f5d7149d29
|
7
|
+
data.tar.gz: fe0b339242ef4ee3ca7f88d43eba25bd148d8a080db8530cf7a4e96c94ea7db1d4bb6c2878c989b848e426b6b1c46878619aff6c429bdeac60523cacaaff99eb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,7 @@ You can build and install this gem on your local system as well via a Rake task:
|
|
25
25
|
| `execution_timeout` | Maximum time until timeout | 60 |
|
26
26
|
| `recheck_invocation` | Interval of rechecking AWS command invocation | 1.0 |
|
27
27
|
| `recheck_execution` | Interval of rechecking completion of command | 1.0 |
|
28
|
+
| `instance_pagesize` | Paging size for EC2 instance retrieval | 100 |
|
28
29
|
|
29
30
|
## Limitations
|
30
31
|
|
@@ -7,7 +7,7 @@ module TrainPlugins
|
|
7
7
|
module AWSSSM
|
8
8
|
class Connection < Train::Plugins::Transport::BaseConnection
|
9
9
|
attr_reader :instance_id, :options
|
10
|
-
attr_writer :ssm, :ec2
|
10
|
+
attr_writer :ssm, :ec2, :instances
|
11
11
|
|
12
12
|
def initialize(options)
|
13
13
|
super(options)
|
@@ -85,8 +85,6 @@ module TrainPlugins
|
|
85
85
|
def resolve_instance_id(address)
|
86
86
|
logger.debug format("[AWS-SSM] Trying to resolve address %s", address)
|
87
87
|
|
88
|
-
instances = ec2.describe_instances.reservations.collect { |r| r.instances.first }
|
89
|
-
|
90
88
|
# Resolve, if DNS name and not Amazon default
|
91
89
|
if dns_name?(address) && !amazon_dns?(address)
|
92
90
|
address = Resolv.getaddress(address)
|
@@ -112,6 +110,28 @@ module TrainPlugins
|
|
112
110
|
raise ArgumentError, format("Error looking up Instance ID for %s: %s", address, e.message)
|
113
111
|
end
|
114
112
|
|
113
|
+
# List up EC2 instances in the account.
|
114
|
+
#
|
115
|
+
# @param [Boolean] cache Cache results
|
116
|
+
# @return [Array] List of instances
|
117
|
+
# @todo Implement paging
|
118
|
+
def instances(caching: true)
|
119
|
+
return @instances unless @instances.nil? || !caching
|
120
|
+
|
121
|
+
results = []
|
122
|
+
|
123
|
+
ec2_instances = ec2.describe_instances(max_results: options[:instance_pagesize])
|
124
|
+
loop do
|
125
|
+
results.concat ec2_instances.reservations.map(&:instances).flatten
|
126
|
+
|
127
|
+
break unless ec2_instances.next_token
|
128
|
+
|
129
|
+
ec2_instances = ec2.describe_instances(max_results: options[:instance_pagesize], next_token: ec2_instances.next_token)
|
130
|
+
end
|
131
|
+
|
132
|
+
@instances = results
|
133
|
+
end
|
134
|
+
|
115
135
|
# Check if this is an IP address
|
116
136
|
#
|
117
137
|
# @param [String] address Host, IP address or other input
|
@@ -11,6 +11,7 @@ module TrainPlugins
|
|
11
11
|
option :execution_timeout, default: 60.0
|
12
12
|
option :recheck_invocation, default: 1.0
|
13
13
|
option :recheck_execution, default: 1.0
|
14
|
+
option :instance_pagesize, default: 100
|
14
15
|
|
15
16
|
def connection(_instance_opts = nil)
|
16
17
|
@connection ||= TrainPlugins::AWSSSM::Connection.new(@options)
|
data/lib/train-awsssm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train-awsssm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Heinen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|