firespring_dev_commands 2.1.32.pre.alpha.2 → 2.1.33.pre.alpha.1
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: c45c76d9855e9cdf1d7366ace69704734d74672fff36ca7f29fb067dbb20b9d1
|
4
|
+
data.tar.gz: 48846c3bda2a4bb1bc6da5572c2cbd3d1736c0348a04f092783b39d1f87e18c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca56922554bce95dcccd9853c8395e887d7957e2c30480998ca1bb24739fab1aef9a6b83c9d12f3eff6f3800480b103e8d603ec88b11bf4c593a86153632ca5c
|
7
|
+
data.tar.gz: 3f509eb7bb98710a2cab435d4d05d75b6da1fda5b75d609a1988535e2a82af0ad6e49eec97a5d406b1e53a31d10be6732f4c6b1d5e070e829feeab335f33423d
|
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
|
+
* (optinoal) Add AWS login template commands
|
32
32
|
```
|
33
33
|
# Configure AWS accounts and create tasks
|
34
34
|
Dev::Aws::Account::configure do |c|
|
@@ -21,9 +21,10 @@ module Dev
|
|
21
21
|
# Finished status
|
22
22
|
FINISHED = :finished
|
23
23
|
|
24
|
-
attr_accessor :client, :name, :template_filename, :parameters, :capabilities, :failure_behavior, :state
|
24
|
+
attr_accessor :client, :name, :template_filename, :parameters, :capabilities, :failure_behavior, :preserve_parameters_on_update, :state
|
25
25
|
|
26
|
-
def initialize(name, template_filename, parameters: Dev::Aws::Cloudformation::Parameters.new, capabilities: [], failure_behavior: 'ROLLBACK'
|
26
|
+
def initialize(name, template_filename, parameters: Dev::Aws::Cloudformation::Parameters.new, capabilities: [], failure_behavior: 'ROLLBACK',
|
27
|
+
preserve_parameters_on_update: false)
|
27
28
|
raise 'parameters must be an intsance of parameters' unless parameters.is_a?(Dev::Aws::Cloudformation::Parameters)
|
28
29
|
|
29
30
|
@client = nil
|
@@ -32,6 +33,7 @@ module Dev
|
|
32
33
|
@parameters = parameters
|
33
34
|
@capabilities = capabilities
|
34
35
|
@failure_behavior = failure_behavior
|
36
|
+
@preserve_parameters_on_update = preserve_parameters_on_update
|
35
37
|
@state = NOT_STARTED
|
36
38
|
end
|
37
39
|
|
@@ -81,11 +83,16 @@ module Dev
|
|
81
83
|
# Call upload function to get the s3 url
|
82
84
|
template_url = upload(template_filename)
|
83
85
|
|
86
|
+
update_parameters = if preserve_parameters_on_update
|
87
|
+
parameters.preserve
|
88
|
+
else
|
89
|
+
parameters.default
|
90
|
+
end
|
84
91
|
# Update the cloudformation stack
|
85
92
|
client.update_stack(
|
86
93
|
stack_name: name,
|
87
94
|
template_url:,
|
88
|
-
parameters:
|
95
|
+
parameters: update_parameters,
|
89
96
|
capabilities:
|
90
97
|
)
|
91
98
|
@state = STARTED
|
@@ -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.
|
4
|
+
version: 2.1.33.pre.alpha.1
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -122,20 +122,6 @@ 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
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: aws-sdk-s3
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -340,7 +326,6 @@ files:
|
|
340
326
|
- lib/firespring_dev_commands/aws/login.rb
|
341
327
|
- lib/firespring_dev_commands/aws/parameter.rb
|
342
328
|
- lib/firespring_dev_commands/aws/profile.rb
|
343
|
-
- lib/firespring_dev_commands/aws/route53.rb
|
344
329
|
- lib/firespring_dev_commands/aws/s3.rb
|
345
330
|
- lib/firespring_dev_commands/bloom_growth.rb
|
346
331
|
- lib/firespring_dev_commands/bloom_growth/rock.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'aws-sdk-route53'
|
2
|
-
|
3
|
-
module Dev
|
4
|
-
class Aws
|
5
|
-
# Class for performing Route53 functions
|
6
|
-
class Route53
|
7
|
-
attr_reader :client, :zones
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@client = ::Aws::Route53::Client.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def hosted_zones(domains)
|
14
|
-
@zones = []
|
15
|
-
if domains.empty?
|
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
|
22
|
-
end
|
23
|
-
else
|
24
|
-
domains.each do |domain_name|
|
25
|
-
zone = client.list_hosted_zones_by_name({dns_name: domain_name, max_items: 1})
|
26
|
-
target_name = zone.hosted_zones.first.name.chomp!('.')
|
27
|
-
@zones << zone.hosted_zones.first.id unless target_name != domain_name
|
28
|
-
end
|
29
|
-
end
|
30
|
-
raise 'Hosted zone(s) not found.' if @zones.empty?
|
31
|
-
end
|
32
|
-
|
33
|
-
def get_target_config_id(zone_id)
|
34
|
-
config = client.list_query_logging_configs(
|
35
|
-
hosted_zone_id: zone_id,
|
36
|
-
max_results: '1'
|
37
|
-
)
|
38
|
-
config.query_logging_configs.first.id unless config.query_logging_configs.empty? || config.query_logging_configs.first.hosted_zone_id == zone_id
|
39
|
-
end
|
40
|
-
|
41
|
-
def activate_query_logging(log_group)
|
42
|
-
output = {}
|
43
|
-
|
44
|
-
@zones.each do |zone|
|
45
|
-
response = client.create_query_logging_config(
|
46
|
-
hosted_zone_id: zone,
|
47
|
-
cloud_watch_logs_log_group_arn: log_group
|
48
|
-
)
|
49
|
-
output[zone] = response.location
|
50
|
-
rescue ::Aws::Route53::Errors::ServiceError => e
|
51
|
-
raise "Error: #{e.message}" unless e.instance_of?(::Aws::Route53::Errors::QueryLoggingConfigAlreadyExists)
|
52
|
-
|
53
|
-
output[zone] = e.message
|
54
|
-
end
|
55
|
-
pp output
|
56
|
-
end
|
57
|
-
|
58
|
-
def deactivate_query_logging
|
59
|
-
output = {}
|
60
|
-
@zones.each do |zone|
|
61
|
-
target_config_id = get_target_config_id(zone)
|
62
|
-
if target_config_id
|
63
|
-
client.delete_query_logging_config(
|
64
|
-
id: target_config_id
|
65
|
-
)
|
66
|
-
output[zone] = 'Query logging config removed.'
|
67
|
-
else
|
68
|
-
output[zone] = 'No query logging config assigned.'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
pp output
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|