firespring_dev_commands 2.1.32.pre.alpha.2 → 2.1.32.pre.alpha.4
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: fdc619a8748de80444363d7bf216ffc4c4ffcb706b2ca9478e4a156203529bb8
|
4
|
+
data.tar.gz: 1195bb833ab7fae4d713bf1c8f6401e83bd3dde8146f7a75fe6ac999be40ad29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d96c11b5828232f415a9f36731ac2e649c07f2be927e24f64b973834db3d2db8d1a5ad80a96fc1ae9485848b964601a435d9208d85f154afabc6ce45355e50
|
7
|
+
data.tar.gz: 709779690537ec9e1a292599c9050f81f8364bcc98d2547f9b13dec3486fcae295a92d504b19a3ca513242731bc514c9a46a8a38677f77db0e0522e92dec4a4e
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'aws-sdk-route53'
|
2
|
-
|
3
1
|
module Dev
|
4
2
|
class Aws
|
5
3
|
# Class for performing Route53 functions
|
@@ -8,34 +6,68 @@ module Dev
|
|
8
6
|
|
9
7
|
def initialize
|
10
8
|
@client = ::Aws::Route53::Client.new
|
9
|
+
@zones = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def zones(domains = [])
|
13
|
+
@zones ||= if domains.empty?
|
14
|
+
all_zones
|
15
|
+
else
|
16
|
+
zones_by_domain_names(domains)
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
response.hosted_zones.each do |hosted_zone|
|
19
|
-
ary << hosted_zone.id unless hosted_zone.config.private_zone
|
20
|
-
end
|
20
|
+
def all_zones
|
21
|
+
[].tap do |ary|
|
22
|
+
Dev::Aws.each_page(client, :list_hosted_zones) do |response|
|
23
|
+
response.hosted_zones&.each do |hosted_zone|
|
24
|
+
ary << hosted_zone unless hosted_zone.config.private_zone
|
21
25
|
end
|
22
26
|
end
|
23
|
-
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def zones_by_domain_names(domains)
|
31
|
+
[].tap do |ary|
|
24
32
|
domains.each do |domain_name|
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
response = client.list_hosted_zones_by_name({dns_name: domain_name})
|
34
|
+
target = response.hosted_zones.find { |it| it.name.chomp('.') == domain_name }
|
35
|
+
raise "The #{domain_name} hosted zone not found." unless target
|
36
|
+
|
37
|
+
ary << target
|
28
38
|
end
|
29
39
|
end
|
30
|
-
raise 'Hosted zone(s) not found.' if @zones.empty?
|
31
40
|
end
|
32
41
|
|
33
|
-
def
|
34
|
-
|
42
|
+
def target_config_id(zone_id)
|
43
|
+
client.list_query_logging_configs(
|
35
44
|
hosted_zone_id: zone_id,
|
36
45
|
max_results: '1'
|
37
|
-
)
|
38
|
-
|
46
|
+
).query_logging_configs&.first&.id
|
47
|
+
end
|
48
|
+
|
49
|
+
def pretty_puts(output)
|
50
|
+
# Find the maximum length of the keys
|
51
|
+
max_key_length = output.keys.map(&:to_s).max_by(&:length).length
|
52
|
+
|
53
|
+
output.each do |key, value|
|
54
|
+
puts "#{key.to_s.ljust(max_key_length)}\t=>\t#{value}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def list_query_configs
|
59
|
+
output = {}
|
60
|
+
@zones.each do |zone|
|
61
|
+
target_config_id = target_config_id(zone.id)
|
62
|
+
|
63
|
+
output[zone.name] = if target_config_id
|
64
|
+
"Config\t=>\t#{target_config_id}".colorize(:green)
|
65
|
+
else
|
66
|
+
'No query logging config assigned.'.colorize(:red)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
pretty_puts(output)
|
39
71
|
end
|
40
72
|
|
41
73
|
def activate_query_logging(log_group)
|
@@ -43,32 +75,32 @@ module Dev
|
|
43
75
|
|
44
76
|
@zones.each do |zone|
|
45
77
|
response = client.create_query_logging_config(
|
46
|
-
hosted_zone_id: zone,
|
78
|
+
hosted_zone_id: zone.id,
|
47
79
|
cloud_watch_logs_log_group_arn: log_group
|
48
80
|
)
|
49
|
-
output[zone] = response.location
|
81
|
+
output[zone.id] = response.location
|
50
82
|
rescue ::Aws::Route53::Errors::ServiceError => e
|
51
83
|
raise "Error: #{e.message}" unless e.instance_of?(::Aws::Route53::Errors::QueryLoggingConfigAlreadyExists)
|
52
84
|
|
53
|
-
output[zone] = e.message
|
85
|
+
output[zone.id] = e.message
|
54
86
|
end
|
55
|
-
|
87
|
+
pretty_puts(output)
|
56
88
|
end
|
57
89
|
|
58
90
|
def deactivate_query_logging
|
59
91
|
output = {}
|
60
92
|
@zones.each do |zone|
|
61
|
-
target_config_id =
|
93
|
+
target_config_id = target_config_id(zone.id)
|
62
94
|
if target_config_id
|
63
95
|
client.delete_query_logging_config(
|
64
96
|
id: target_config_id
|
65
97
|
)
|
66
|
-
output[zone] = 'Query logging config removed.'
|
98
|
+
output[zone.id] = 'Query logging config removed.'.colorize(:green)
|
67
99
|
else
|
68
|
-
output[zone] = 'No query logging config assigned.'
|
100
|
+
output[zone.id] = 'No query logging config assigned.'.colorize(:red)
|
69
101
|
end
|
70
102
|
end
|
71
|
-
|
103
|
+
pretty_puts(output)
|
72
104
|
end
|
73
105
|
end
|
74
106
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require_relative '../../base_interface'
|
2
|
+
|
3
|
+
module Dev
|
4
|
+
module Template
|
5
|
+
class Aws
|
6
|
+
module Services
|
7
|
+
# Class contains rake templates for managing your AWS settings and logging in
|
8
|
+
class Route53 < Dev::Template::BaseInterface
|
9
|
+
# Create the rake task which ensures active credentials are present
|
10
|
+
def create_ensure_credentials_task!
|
11
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
12
|
+
exclude = @exclude
|
13
|
+
|
14
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
15
|
+
return if exclude.include?(:ensure_aws_credentials)
|
16
|
+
|
17
|
+
task ensure_aws_credentials: %w(init) do
|
18
|
+
raise 'AWS Credentials not found / expired' unless Dev::Aws::Credentials.new.active?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Create the rake task for the hosted zone method
|
24
|
+
def create_dns_logging_activate_task!
|
25
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
26
|
+
exclude = @exclude
|
27
|
+
|
28
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
29
|
+
namespace :aws do
|
30
|
+
return if exclude.include?(:dns_logging)
|
31
|
+
|
32
|
+
namespace :hosted_zone do
|
33
|
+
namespace :dns_logging do
|
34
|
+
desc 'Activates query logging for all hosted zones by default.' \
|
35
|
+
'This command should be run from the account the hosted zone(s) reside.' \
|
36
|
+
"\n\t(Required) Specify HOSTED_ZONE_GROUP='arn:aws:logs:REGION:ACCOUNT_ID:' to specify the ARN of the target log group." \
|
37
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
38
|
+
"\n\t\tComma delimited list."
|
39
|
+
task activate: %w(ensure_aws_credentials) do
|
40
|
+
route53 = Dev::Aws::Route53.new
|
41
|
+
route53.zones(ENV['DOMAINS'].to_s.strip.split(','))
|
42
|
+
# Use user defined log group.
|
43
|
+
log_group = ENV.fetch('HOSTED_ZONE_GROUP', nil)
|
44
|
+
raise 'The Hosted Zone Log Group ARN, HOSTED_ZONE_GROUP, is required' unless log_group
|
45
|
+
|
46
|
+
route53.activate_query_logging(log_group)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create the rake task for the hosted zone method
|
55
|
+
def create_dns_logging_deactivate_task!
|
56
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
57
|
+
exclude = @exclude
|
58
|
+
|
59
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
60
|
+
namespace :aws do
|
61
|
+
return if exclude.include?(:dns_logging)
|
62
|
+
|
63
|
+
namespace :hosted_zone do
|
64
|
+
namespace :dns_logging do
|
65
|
+
desc 'Deactivates query logging for all hosted zones by default. ' \
|
66
|
+
'This command should be run from the account the hosted zone(s) reside.' \
|
67
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
68
|
+
"\n\t\tComma delimited list."
|
69
|
+
task deactivate: %w(ensure_aws_credentials) do
|
70
|
+
route53 = Dev::Aws::Route53.new
|
71
|
+
route53.zones(ENV['DOMAINS'].to_s.strip.split(','))
|
72
|
+
route53.deactivate_query_logging
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Create the rake task for the hosted zone method
|
81
|
+
def create_list_query_config_task!
|
82
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
83
|
+
exclude = @exclude
|
84
|
+
|
85
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
86
|
+
namespace :aws do
|
87
|
+
return if exclude.include?(:dns_logging)
|
88
|
+
|
89
|
+
namespace :hosted_zone do
|
90
|
+
namespace :dns_logging do
|
91
|
+
desc 'Lists the current config for domain(s). ' \
|
92
|
+
'This command should be run from the account the hosted zone(s) reside.' \
|
93
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
94
|
+
"\n\t\tComma delimited list."
|
95
|
+
task list_query_configs: %w(ensure_aws_credentials) do
|
96
|
+
route53 = Dev::Aws::Route53.new
|
97
|
+
route53.zones(ENV['DOMAINS'].to_s.strip.split(','))
|
98
|
+
route53.list_query_configs
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -120,61 +120,6 @@ module Dev
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
|
-
|
124
|
-
# Create the rake task for the hosted zone method
|
125
|
-
def create_dns_logging_activate_task!
|
126
|
-
# Have to set a local variable to be accessible inside of the instance_eval block
|
127
|
-
exclude = @exclude
|
128
|
-
|
129
|
-
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
130
|
-
namespace :aws do
|
131
|
-
return if exclude.include?(:dns_logging)
|
132
|
-
|
133
|
-
namespace :hosted_zone do
|
134
|
-
namespace :dns_logging do
|
135
|
-
desc 'Activates query logging for all hosted zones by default.' \
|
136
|
-
'This command should be run from the account the hosted zone(s) reside.' \
|
137
|
-
"\n\toptionally specify HOSTED_ZONE_GROUP='arn:aws:logs:REGION:ACCOUNT_ID:' to specify the ARN of the target log group." \
|
138
|
-
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
139
|
-
"\n\t\tComma delimited list."
|
140
|
-
task :activate do
|
141
|
-
route53 = Dev::Aws::Route53.new
|
142
|
-
route53.hosted_zones(ENV['DOMAINS'].to_s.strip.split(','))
|
143
|
-
# Use user defined log group. Otherwise, go get the default.
|
144
|
-
log_group = (ENV['HOSTED_ZONE_GROUP'] || Dev::Aws::Parameter.new.get_value('/Firespring/Internal/Route53/hosted-zone/log-group-arn'))
|
145
|
-
route53.activate_query_logging(log_group)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
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
|
164
|
-
desc 'Deactivates query logging for all hosted zones by default. ' \
|
165
|
-
'This command should be run from the account the hosted zone(s) reside.' \
|
166
|
-
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
167
|
-
"\n\t\tComma delimited list."
|
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
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
123
|
end
|
179
124
|
end
|
180
125
|
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.4
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -399,6 +399,7 @@ files:
|
|
399
399
|
- lib/firespring_dev_commands/target_process/user_story.rb
|
400
400
|
- lib/firespring_dev_commands/target_process/user_story_history.rb
|
401
401
|
- lib/firespring_dev_commands/templates/aws.rb
|
402
|
+
- lib/firespring_dev_commands/templates/aws/services/route53.rb
|
402
403
|
- lib/firespring_dev_commands/templates/base_interface.rb
|
403
404
|
- lib/firespring_dev_commands/templates/certificate.rb
|
404
405
|
- lib/firespring_dev_commands/templates/ci.rb
|