firespring_dev_commands 2.1.34.pre.alpha.1 → 2.1.34
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: aa188df0b1a042594409df9d0c288298a1c2899ccf0a420f213f34f6bd463950
|
4
|
+
data.tar.gz: 474383072092cf5be3bbbcc5c92dcb5b0fbfc426a55ce93dd46e174e6a3b9217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d21358d2fcd8fe2dfed28327c553b6795e7095433ff6667d41bcca6d89268ab03367a0a166535d53d1623368716aadb15bcda65f24eb18e40efd895e7147d20
|
7
|
+
data.tar.gz: 20a2bedaed3177859237c8d3cf4e7ab36c4d8382906068bd489456617de50cfd430a4c145afe917b4acb1963bd76435dd51fde2898ae5ed5190c1ba6b4af89a3
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Dev::Template::Docker::Node::Application.new('foo')
|
|
28
28
|
```
|
29
29
|
* If you run `rake -T` now, you should have base rake commands and application rake commands for an app called `foo`
|
30
30
|
|
31
|
-
* (
|
31
|
+
* (optional) Add AWS login template commands
|
32
32
|
```
|
33
33
|
# Configure AWS accounts and create tasks
|
34
34
|
Dev::Aws::Account::configure do |c|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Dev
|
2
|
+
class Aws
|
3
|
+
# Class for performing Route53 functions
|
4
|
+
class Route53
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
def initialize(domains)
|
8
|
+
@client = ::Aws::Route53::Client.new
|
9
|
+
@domains = domains
|
10
|
+
end
|
11
|
+
|
12
|
+
private def zones
|
13
|
+
if @domains.empty?
|
14
|
+
all_zones
|
15
|
+
else
|
16
|
+
zones_by_domain_names(@domains)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private 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
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private def zones_by_domain_names(domains)
|
31
|
+
[].tap do |ary|
|
32
|
+
domains.each do |domain_name|
|
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
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private def target_config_id(zone_id)
|
43
|
+
client.list_query_logging_configs(
|
44
|
+
hosted_zone_id: zone_id,
|
45
|
+
max_results: '1'
|
46
|
+
).query_logging_configs&.first&.id
|
47
|
+
end
|
48
|
+
|
49
|
+
private 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)
|
71
|
+
end
|
72
|
+
|
73
|
+
def activate_query_logging(log_group)
|
74
|
+
output = {}
|
75
|
+
|
76
|
+
zones.each do |zone|
|
77
|
+
response = client.create_query_logging_config(
|
78
|
+
hosted_zone_id: zone.id,
|
79
|
+
cloud_watch_logs_log_group_arn: log_group
|
80
|
+
)
|
81
|
+
output[zone.id] = response.location
|
82
|
+
rescue ::Aws::Route53::Errors::ServiceError => e
|
83
|
+
raise "Error: #{e.message}" unless e.instance_of?(::Aws::Route53::Errors::QueryLoggingConfigAlreadyExists)
|
84
|
+
|
85
|
+
output[zone.id] = e.message
|
86
|
+
end
|
87
|
+
pretty_puts(output)
|
88
|
+
end
|
89
|
+
|
90
|
+
def deactivate_query_logging
|
91
|
+
output = {}
|
92
|
+
zones.each do |zone|
|
93
|
+
target_config_id = target_config_id(zone.id)
|
94
|
+
if target_config_id
|
95
|
+
client.delete_query_logging_config(
|
96
|
+
id: target_config_id
|
97
|
+
)
|
98
|
+
output[zone.id] = 'Query logging config removed.'.colorize(:green)
|
99
|
+
else
|
100
|
+
output[zone.id] = 'No query logging config assigned.'.colorize(:red)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
pretty_puts(output)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,106 @@
|
|
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 LOG_GROUP_ARN='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(ENV['DOMAINS'].to_s.strip.split(','))
|
41
|
+
# Use user defined log group.
|
42
|
+
log_group = ENV.fetch('LOG_GROUP_ARN', nil)
|
43
|
+
raise 'The Hosted Zone Log Group ARN, LOG_GROUP_ARN, is required' unless log_group
|
44
|
+
|
45
|
+
route53.activate_query_logging(log_group)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create the rake task for the hosted zone method
|
54
|
+
def create_dns_logging_deactivate_task!
|
55
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
56
|
+
exclude = @exclude
|
57
|
+
|
58
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
59
|
+
namespace :aws do
|
60
|
+
return if exclude.include?(:dns_logging)
|
61
|
+
|
62
|
+
namespace :hosted_zone do
|
63
|
+
namespace :dns_logging do
|
64
|
+
desc 'Deactivates query logging for all hosted zones by default. ' \
|
65
|
+
'This command should be run from the account the hosted zone(s) reside.' \
|
66
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
67
|
+
"\n\t\tComma delimited list."
|
68
|
+
task deactivate: %w(ensure_aws_credentials) do
|
69
|
+
route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
|
70
|
+
route53.deactivate_query_logging
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Create the rake task for the hosted zone method
|
79
|
+
def create_list_query_config_task!
|
80
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
81
|
+
exclude = @exclude
|
82
|
+
|
83
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
84
|
+
namespace :aws do
|
85
|
+
return if exclude.include?(:dns_logging)
|
86
|
+
|
87
|
+
namespace :hosted_zone do
|
88
|
+
namespace :dns_logging do
|
89
|
+
desc 'Lists the current config for domain(s). ' \
|
90
|
+
'This command should be run from the account the hosted zone(s) reside.' \
|
91
|
+
"\n\toptionally specify DOMAINS='foo.com,foobar.com' to specify the hosted zones to activate." \
|
92
|
+
"\n\t\tComma delimited list."
|
93
|
+
task list_query_configs: %w(ensure_aws_credentials) do
|
94
|
+
route53 = Dev::Aws::Route53.new(ENV['DOMAINS'].to_s.strip.split(','))
|
95
|
+
route53.list_query_configs
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
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.34
|
4
|
+
version: 2.1.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.208.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: aws-sdk-route53
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.87.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.87.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: aws-sdk-s3
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -326,6 +340,7 @@ files:
|
|
326
340
|
- lib/firespring_dev_commands/aws/login.rb
|
327
341
|
- lib/firespring_dev_commands/aws/parameter.rb
|
328
342
|
- lib/firespring_dev_commands/aws/profile.rb
|
343
|
+
- lib/firespring_dev_commands/aws/route53.rb
|
329
344
|
- lib/firespring_dev_commands/aws/s3.rb
|
330
345
|
- lib/firespring_dev_commands/bloom_growth.rb
|
331
346
|
- lib/firespring_dev_commands/bloom_growth/rock.rb
|
@@ -385,6 +400,7 @@ files:
|
|
385
400
|
- lib/firespring_dev_commands/target_process/user_story.rb
|
386
401
|
- lib/firespring_dev_commands/target_process/user_story_history.rb
|
387
402
|
- lib/firespring_dev_commands/templates/aws.rb
|
403
|
+
- lib/firespring_dev_commands/templates/aws/services/route53.rb
|
388
404
|
- lib/firespring_dev_commands/templates/base_interface.rb
|
389
405
|
- lib/firespring_dev_commands/templates/certificate.rb
|
390
406
|
- lib/firespring_dev_commands/templates/ci.rb
|
@@ -413,9 +429,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
413
429
|
version: '3.1'
|
414
430
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
415
431
|
requirements:
|
416
|
-
- - "
|
432
|
+
- - ">="
|
417
433
|
- !ruby/object:Gem::Version
|
418
|
-
version:
|
434
|
+
version: '0'
|
419
435
|
requirements: []
|
420
436
|
rubygems_version: 3.4.10
|
421
437
|
signing_key:
|