infopark-aws_utils 0.8.1 → 1.0.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 +5 -5
- data/lib/infopark/aws_utils/env.rb +29 -15
- data/lib/infopark/aws_utils/version.rb +1 -1
- data/lib/infopark/aws_utils.rb +4 -5
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8d3e58deae1c3f55e18b551ebbfb40572e1e4ff815b53d82f88e3c864289efa
|
4
|
+
data.tar.gz: 353a64a595b54c01154ea956a68734de2bf3224dca43d7a4b6bf502e5031040e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e9fa7c93e45577e8773dba59565033f7c7612740adfbd2db6fecfc9de08f9ef87523891f7406ae847a78ded73d852db7484e47fa853e9afb3731e852f275cb0
|
7
|
+
data.tar.gz: 6a1fe70450d9c804a831add17ac1b8fb08b37f1af99186f6c13f758aa84bfdbcc6a7f9f823457f36001ccaeed2e5df3a0be8dc4eb87ad876e7d2e157dc6368a5
|
@@ -110,18 +110,22 @@ class Env
|
|
110
110
|
else
|
111
111
|
raise "invalid root_device_type: #{root_device_type}"
|
112
112
|
end
|
113
|
-
available_images = AwsUtils.gather_all(
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
]
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
113
|
+
available_images = AwsUtils.gather_all(
|
114
|
+
client: ec2,
|
115
|
+
method: :describe_images,
|
116
|
+
response_key: :image_details,
|
117
|
+
owners: [AWS_AMI_OWNER],
|
118
|
+
filters: [
|
119
|
+
{name: "root-device-type", values: root_device_filter_value},
|
120
|
+
{name: "ena-support", values: ["true"]},
|
121
|
+
{name: "image-type", values: ["machine"]},
|
122
|
+
{name: "virtualization-type", values: ["hvm"]},
|
123
|
+
],
|
124
|
+
)
|
125
|
+
.reject {|image| image.name.include?(".rc-") }
|
126
|
+
.reject {|image| image.name.include?("-minimal-") }
|
127
|
+
.reject {|image| image.name.include?("-test") }
|
128
|
+
.reject {|image| image.name.include?("amzn-ami-vpc-nat-") }
|
125
129
|
(reject_image_name_patterns || []).each do |pattern|
|
126
130
|
available_images.reject! {|image| image.name =~ pattern }
|
127
131
|
end
|
@@ -129,12 +133,22 @@ class Env
|
|
129
133
|
end
|
130
134
|
|
131
135
|
def find_image_by_id(id)
|
132
|
-
AwsUtils.gather_all(
|
136
|
+
AwsUtils.gather_all(
|
137
|
+
client: ec2,
|
138
|
+
method: :describe_images,
|
139
|
+
response_key: :image_details,
|
140
|
+
image_ids: [id],
|
141
|
+
).first
|
133
142
|
end
|
134
143
|
|
135
144
|
def find_image_by_name(name)
|
136
|
-
AwsUtils.gather_all(
|
137
|
-
|
145
|
+
AwsUtils.gather_all(
|
146
|
+
client: ec2,
|
147
|
+
method: :describe_images,
|
148
|
+
response_key: :image_details,
|
149
|
+
owners: [DEV_ACCOUNT_ID],
|
150
|
+
filters: [{name: "name", values: [name]}],
|
151
|
+
).first
|
138
152
|
end
|
139
153
|
|
140
154
|
private
|
data/lib/infopark/aws_utils.rb
CHANGED
@@ -6,7 +6,7 @@ module Infopark
|
|
6
6
|
AWS_AMI_OWNER = "137112412989"
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def gather_all(client
|
9
|
+
def gather_all(client:, method:, response_key:, **options)
|
10
10
|
unless block_given?
|
11
11
|
@gather_cache ||= {}
|
12
12
|
cache_key = [client, method, options]
|
@@ -16,14 +16,13 @@ module Infopark
|
|
16
16
|
result = []
|
17
17
|
loop do
|
18
18
|
response = retry_on_throttle { client.send(method, **options) }
|
19
|
-
key = (response.members - [:next_token, :failures]).first
|
20
19
|
if response.members.include?(:failures) && !response.failures.empty?
|
21
20
|
raise "Failed gathering all #{method}: #{response.failures}"
|
22
21
|
end
|
23
22
|
if block_given?
|
24
|
-
response[
|
23
|
+
response[response_key].each {|entity| retry_on_throttle { yield entity } }
|
25
24
|
else
|
26
|
-
result += response[
|
25
|
+
result += response[response_key]
|
27
26
|
end
|
28
27
|
unless options[:next_token] = response.members.include?(:next_token) && response.next_token
|
29
28
|
break
|
@@ -45,7 +44,7 @@ module Infopark
|
|
45
44
|
def local_config
|
46
45
|
@local_config ||= (
|
47
46
|
path = "#{Dir.home}/.config/infopark/aws_utils.json"
|
48
|
-
if File.
|
47
|
+
if File.exist?(path)
|
49
48
|
JSON.parse(File.read(path))
|
50
49
|
else
|
51
50
|
{}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark-aws_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilo Prütz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-applicationautoscaling
|
@@ -181,11 +181,11 @@ files:
|
|
181
181
|
- lib/infopark/aws_utils/version.rb
|
182
182
|
- spec/env_spec.rb
|
183
183
|
- spec/spec_helper.rb
|
184
|
-
homepage:
|
184
|
+
homepage:
|
185
185
|
licenses:
|
186
186
|
- UNLICENSED
|
187
187
|
metadata: {}
|
188
|
-
post_install_message:
|
188
|
+
post_install_message:
|
189
189
|
rdoc_options: []
|
190
190
|
require_paths:
|
191
191
|
- lib
|
@@ -200,9 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
|
-
|
204
|
-
|
205
|
-
signing_key:
|
203
|
+
rubygems_version: 3.4.10
|
204
|
+
signing_key:
|
206
205
|
specification_version: 4
|
207
206
|
summary: A utility lib to ease the use of the AWS SDK
|
208
207
|
test_files: []
|