firespring_dev_commands 2.1.32.pre.alpha.1 → 2.1.32.pre.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87dcece3099e1aec9bfb5f6572371479e6c5cd2dae608d126fc1f5a124a84f7e
|
4
|
+
data.tar.gz: b1204325e48a239995de507fc320331aa6a4dd353338085e9512aefd46f82dcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4331459a1711d98a385e3babbaac972f72c01010fb41e5fe535934427a0a804690ae24ebfd4f33c1f59818a3ac520fd0aa3afe369739a5d86d5b80fd0e8676b1
|
7
|
+
data.tar.gz: bdfb0873f8ad0da53076a979fd60010af02d97894edf538dc3e72ffd97379fadc93a0623f3040d15a820005acd93232df11641b9f12b9a6957a5f8b43cba63e8
|
@@ -8,31 +8,35 @@ module Dev
|
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@client = ::Aws::Route53::Client.new
|
11
|
-
@zones = []
|
12
11
|
end
|
13
12
|
|
14
|
-
def
|
13
|
+
def hosted_zones(domains)
|
14
|
+
@zones = []
|
15
15
|
if domains.empty?
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
@zones = [].tap do |ary|
|
17
|
+
Dev::Aws.each_page(client, :list_hosted_zones, {max_items: 2}) do |response|
|
18
|
+
response.hosted_zones.each do |hosted_zone|
|
19
|
+
ary << hosted_zone.id unless hosted_zone.config.private_zone
|
20
|
+
end
|
21
|
+
end
|
19
22
|
end
|
20
23
|
else
|
21
24
|
domains.each do |domain_name|
|
22
25
|
zone = client.list_hosted_zones_by_name({dns_name: domain_name, max_items: 1})
|
23
|
-
target_name = zone.hosted_zones
|
24
|
-
|
26
|
+
target_name = zone.hosted_zones.first.name.chomp!('.')
|
27
|
+
raise "The #{domain_name} hosted zone not found." if target_name != domain_name
|
28
|
+
|
29
|
+
@zones << zone.hosted_zones.first.id
|
25
30
|
end
|
26
31
|
end
|
27
32
|
raise 'Hosted zone(s) not found.' if @zones.empty?
|
28
33
|
end
|
29
34
|
|
30
35
|
def get_target_config_id(zone_id)
|
31
|
-
|
36
|
+
client.list_query_logging_configs(
|
32
37
|
hosted_zone_id: zone_id,
|
33
38
|
max_results: '1'
|
34
|
-
)
|
35
|
-
config.query_logging_configs[0].id unless config.query_logging_configs.empty? || config.query_logging_configs[0].hosted_zone_id == zone_id
|
39
|
+
).query_logging_configs.first.id
|
36
40
|
end
|
37
41
|
|
38
42
|
def activate_query_logging(log_group)
|
@@ -121,56 +121,60 @@ module Dev
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
# rubocop:disable Metrics/MethodLength
|
125
124
|
# Create the rake task for the hosted zone method
|
126
|
-
def
|
125
|
+
def create_dns_logging_activate_task!
|
127
126
|
# Have to set a local variable to be accessible inside of the instance_eval block
|
128
127
|
exclude = @exclude
|
129
128
|
|
130
129
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
131
130
|
namespace :aws do
|
132
|
-
return if exclude.include?(:
|
131
|
+
return if exclude.include?(:dns_logging)
|
133
132
|
|
134
133
|
namespace :hosted_zone do
|
135
134
|
namespace :dns_logging do
|
136
|
-
task :init do
|
137
|
-
@route53 = Dev::Aws::Route53.new
|
138
|
-
|
139
|
-
domains = ENV['DOMAINS'].to_s.strip.split(',')
|
140
|
-
domain = ENV['DOMAIN'].to_s.strip
|
141
|
-
domains << domain unless domain.empty?
|
142
|
-
|
143
|
-
# Set global zone id array
|
144
|
-
@route53.get_hosted_zones(domains)
|
145
|
-
end
|
146
|
-
|
147
135
|
desc 'Activates query logging for all hosted zones by default.' \
|
148
136
|
'This command should be run from the account the hosted zone(s) reside.' \
|
149
137
|
"\n\toptionally specify HOSTED_ZONE_GROUP='arn:aws:logs:REGION:ACCOUNT_ID:' to specify the ARN of the target log group." \
|
150
|
-
"\n\toptionally specify DOMAIN='foo.com' to specify the hosted zone to activate." \
|
151
138
|
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
152
139
|
"\n\t\tComma delimited list."
|
153
|
-
task activate
|
140
|
+
task :activate do
|
141
|
+
route53 = Dev::Aws::Route53.new
|
142
|
+
route53.hosted_zones(ENV['DOMAINS'].to_s.strip.split(','))
|
154
143
|
# Use user defined log group. Otherwise, go get the default.
|
155
144
|
log_group = (ENV['HOSTED_ZONE_GROUP'] || Dev::Aws::Parameter.new.get_value('/Firespring/Internal/Route53/hosted-zone/log-group-arn'))
|
156
|
-
|
157
|
-
@route53.activate_query_logging(log_group)
|
145
|
+
route53.activate_query_logging(log_group)
|
158
146
|
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
159
152
|
|
153
|
+
# Create the rake task for the hosted zone method
|
154
|
+
def create_dns_logging_deactivate_task!
|
155
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
156
|
+
exclude = @exclude
|
157
|
+
|
158
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
159
|
+
namespace :aws do
|
160
|
+
return if exclude.include?(:dns_logging_de)
|
161
|
+
|
162
|
+
namespace :hosted_zone do
|
163
|
+
namespace :dns_logging do
|
160
164
|
desc 'Deactivates query logging for all hosted zones by default. ' \
|
161
165
|
'This command should be run from the account the hosted zone(s) reside.' \
|
162
|
-
"\n\toptionally specify DOMAIN='foo.com' to specify the hosted zone to activate." \
|
163
166
|
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
164
167
|
"\n\t\tComma delimited list."
|
165
|
-
task deactivate
|
166
|
-
|
168
|
+
task :deactivate do
|
169
|
+
route53 = Dev::Aws::Route53.new
|
170
|
+
route53.hosted_zones(ENV['DOMAINS'].to_s.strip.split(','))
|
171
|
+
route53.deactivate_query_logging
|
167
172
|
end
|
168
173
|
end
|
169
174
|
end
|
170
175
|
end
|
171
176
|
end
|
172
177
|
end
|
173
|
-
# rubocop:enable Metrics/MethodLength
|
174
178
|
end
|
175
179
|
end
|
176
180
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firespring_dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.32.pre.alpha.
|
4
|
+
version: 2.1.32.pre.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|