stax 0.1.9 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/stax +3 -1
- data/lib/stax/base.rb +8 -0
- data/lib/stax/cli/ls.rb +17 -11
- data/lib/stax/cli.rb +1 -0
- data/lib/stax/mixin/cloudfront.rb +26 -0
- data/lib/stax/mixin/rds.rb +19 -0
- data/lib/stax/stack/parameters.rb +1 -1
- data/lib/stax/version.rb +1 -1
- data/lib/stax.rb +17 -17
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e06118c5b0a768644f923c855812c3002ffec3450c7721003845d2a176fb9f81
|
4
|
+
data.tar.gz: e4796b95cdee6858736d9661d095ce9965a66a8c6ec3e7a0aaa39de4d924421b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97786ca4626333936c74672410f84a78095b2346d9b0d1917acdffcd597f89c5ff57e022a2bf183414bd35bd0bfe19fa5a2d19a5cb3866744e24f0017ad918f
|
7
|
+
data.tar.gz: 46fc1bd32ba9debc7c56ce942dd6ee13fbfe7a73e19c1c87b57ba1a50481e90a9ca0d8f81fff35d169c52391657e9df3030ecb5f20ff3cfc38a2dbc32dcd3071
|
data/bin/stax
CHANGED
@@ -5,6 +5,8 @@ require 'stax'
|
|
5
5
|
Stax.load_staxfile
|
6
6
|
begin
|
7
7
|
Stax::Cli.start(ARGV)
|
8
|
-
rescue Aws::CloudFormation::Errors::ExpiredToken
|
8
|
+
rescue Aws::CloudFormation::Errors::ExpiredToken,
|
9
|
+
Aws::CloudFormation::Errors::ValidationError,
|
10
|
+
Aws::Errors::MissingCredentialsError => e
|
9
11
|
abort(e.message)
|
10
12
|
end
|
data/lib/stax/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'stax/aws/sts'
|
3
|
+
require 'aws-sdk-ssm'
|
3
4
|
|
4
5
|
## clean exit on ctrl-c for all methods
|
5
6
|
trap('SIGINT', 'EXIT')
|
@@ -28,6 +29,13 @@ module Stax
|
|
28
29
|
@_aws_region ||= ENV['AWS_REGION']
|
29
30
|
end
|
30
31
|
|
32
|
+
## we commonly want to lookup SSM parameters to use as stack parameters
|
33
|
+
def aws_ssm_get(name, region: nil)
|
34
|
+
::Aws::SSM::Client.new({region: region}.compact).get_parameter(name: name)&.parameter&.value
|
35
|
+
rescue ::Aws::SSM::Errors::ParameterNotFound
|
36
|
+
fail_task("#{name} not found in #{region||aws_region}")
|
37
|
+
end
|
38
|
+
|
31
39
|
## find or create a stack object
|
32
40
|
def stack(id)
|
33
41
|
c = id.to_s.split(/[_-]/).map(&:capitalize).join # convert symbol to class string
|
data/lib/stax/cli/ls.rb
CHANGED
@@ -2,37 +2,43 @@ module Stax
|
|
2
2
|
class Cli < Base
|
3
3
|
|
4
4
|
no_commands do
|
5
|
+
## fields to show in output
|
6
|
+
def ls_stack_fields(s)
|
7
|
+
[ s.stack_name, s.creation_time, color(s.stack_status, Aws::Cfn::COLORS) ]
|
8
|
+
end
|
9
|
+
|
10
|
+
## list stacks from Staxfile in given order
|
5
11
|
def ls_staxfile_stacks
|
6
|
-
stacks = Aws::Cfn.stacks.each_with_object({}) { |s, h| h[s.stack_name] = s }
|
7
12
|
print_table Stax.stack_list.map { |id|
|
8
13
|
name = stack(id).stack_name
|
9
|
-
if (s =
|
10
|
-
|
14
|
+
if (s = Aws::Cfn.describe(name))
|
15
|
+
ls_stack_fields(s)
|
11
16
|
else
|
12
|
-
|
17
|
+
[ name, '-' ]
|
13
18
|
end
|
14
|
-
}
|
19
|
+
}
|
15
20
|
end
|
16
21
|
|
22
|
+
## list all extant stacks we think match our prefix
|
17
23
|
def ls_stacks_with_prefix(prefix)
|
18
24
|
print_table Aws::Cfn.stacks.select { |s|
|
19
25
|
s.stack_name.start_with?(prefix || stack_prefix)
|
20
26
|
}.map { |s|
|
21
|
-
|
27
|
+
ls_stack_fields(s)
|
22
28
|
}.sort
|
23
29
|
end
|
24
30
|
|
31
|
+
## list all stacks in account
|
25
32
|
def ls_account_stacks
|
26
33
|
print_table Aws::Cfn.stacks.map { |s|
|
27
|
-
|
34
|
+
ls_stack_fields(s)
|
28
35
|
}.sort
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
39
|
desc 'ls [PREFIX]', 'list stacks'
|
33
|
-
method_option :
|
34
|
-
method_option :
|
35
|
-
method_option :account, aliases: '-A', type: :boolean, default: false, desc: 'list all running stacks in account'
|
40
|
+
method_option :all, aliases: '-a', type: :boolean, default: false, desc: 'list all running stacks with our prefix'
|
41
|
+
method_option :account, aliases: '-A', type: :boolean, default: false, desc: 'list all running stacks in account'
|
36
42
|
def ls(prefix = nil)
|
37
43
|
if options[:account]
|
38
44
|
ls_account_stacks
|
@@ -44,4 +50,4 @@ module Stax
|
|
44
50
|
end
|
45
51
|
|
46
52
|
end
|
47
|
-
end
|
53
|
+
end
|
data/lib/stax/cli.rb
CHANGED
@@ -9,6 +9,7 @@ module Stax
|
|
9
9
|
class Cli < Base
|
10
10
|
class_option :branch, type: :string, default: Git.branch, desc: 'git branch to use'
|
11
11
|
class_option :app, type: :string, default: File.basename(Git.toplevel), desc: 'application name'
|
12
|
+
|
12
13
|
## silence deprecation warning
|
13
14
|
## https://github.com/erikhuda/thor/blob/fb625b223465692a9d8a88cc2a483e126f1a8978/CHANGELOG.md#100
|
14
15
|
def self.exit_on_failure?
|
@@ -62,6 +62,32 @@ module Stax
|
|
62
62
|
}
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
## https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/viewing-cloudfront-metrics.html#monitoring-console.distributions-additional
|
67
|
+
## this is not supported by cfn, see:
|
68
|
+
## https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/545
|
69
|
+
desc 'monitoring', 'control monitoring subscriptions'
|
70
|
+
method_option :enable, aliases: '-e', type: :boolean, description: 'enable additional metrics'
|
71
|
+
method_option :disable, aliases: '-d', type: :boolean, description: 'disable additional metrics'
|
72
|
+
def monitoring
|
73
|
+
client = Aws::Cloudfront.client
|
74
|
+
stack_cloudfront_ids.each do |id|
|
75
|
+
debug("Cloudfront monitoring for distribution #{id}")
|
76
|
+
if options[:enable]
|
77
|
+
sub = { realtime_metrics_subscription_config: { realtime_metrics_subscription_status: :Enabled } }
|
78
|
+
resp = client.create_monitoring_subscription(distribution_id: id, monitoring_subscription: sub)
|
79
|
+
puts resp.monitoring_subscription.realtime_metrics_subscription_config&.realtime_metrics_subscription_status
|
80
|
+
elsif options[:disable]
|
81
|
+
puts 'deleting subscription'
|
82
|
+
client.delete_monitoring_subscription(distribution_id: id)
|
83
|
+
else
|
84
|
+
cfg = client.get_monitoring_subscription(distribution_id: id)&.monitoring_subscription&.realtime_metrics_subscription_config
|
85
|
+
puts "current status: #{cfg&.realtime_metrics_subscription_status}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
65
90
|
end
|
91
|
+
|
66
92
|
end
|
67
93
|
end
|
data/lib/stax/mixin/rds.rb
CHANGED
@@ -158,6 +158,25 @@ module Stax
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
+
desc 'write-forwarding', 'control write-forwarding'
|
162
|
+
method_option :disable, aliases: '-d', type: :boolean, desc: 'disable write-forwarding'
|
163
|
+
method_option :enable, aliases: '-e', type: :boolean, desc: 'enable write-forwarding'
|
164
|
+
def write_forwarding
|
165
|
+
stack_db_clusters.map(&:physical_resource_id).each do |cluster|
|
166
|
+
if options[:enable]
|
167
|
+
puts "#{cluster} enabling write-forwarding"
|
168
|
+
Aws::Rds.client.modify_db_cluster(db_cluster_identifier: cluster, enable_global_write_forwarding: true)
|
169
|
+
elsif options[:disable]
|
170
|
+
puts "#{cluster} disabling write-forwarding"
|
171
|
+
Aws::Rds.client.modify_db_cluster(db_cluster_identifier: cluster, enable_global_write_forwarding: false)
|
172
|
+
else
|
173
|
+
print_table Aws::Rds.client.describe_db_clusters(db_cluster_identifier: cluster).db_clusters.map { |c|
|
174
|
+
[ c.db_cluster_identifier, c.global_write_forwarding_status || '-' ]
|
175
|
+
}
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
161
180
|
end
|
162
181
|
end
|
163
182
|
end
|
data/lib/stax/version.rb
CHANGED
data/lib/stax.rb
CHANGED
@@ -20,26 +20,26 @@ require 'stax/stack/exports'
|
|
20
20
|
require 'stax/stack/resources'
|
21
21
|
require 'stax/stack/drift'
|
22
22
|
|
23
|
-
require 'stax/mixin/ec2'
|
24
|
-
require 'stax/mixin/alb'
|
25
|
-
require 'stax/mixin/elb'
|
26
|
-
require 'stax/mixin/sg'
|
23
|
+
# require 'stax/mixin/ec2'
|
24
|
+
# require 'stax/mixin/alb'
|
25
|
+
# require 'stax/mixin/elb'
|
26
|
+
# require 'stax/mixin/sg'
|
27
27
|
require 'stax/mixin/s3'
|
28
|
-
require 'stax/mixin/asg'
|
29
|
-
require 'stax/mixin/ecs'
|
30
|
-
require 'stax/mixin/ecr'
|
31
|
-
require 'stax/mixin/sqs'
|
32
|
-
require 'stax/mixin/kms'
|
33
|
-
require 'stax/mixin/ssm'
|
34
|
-
require 'stax/mixin/keypair'
|
35
|
-
require 'stax/mixin/emr'
|
36
|
-
require 'stax/mixin/ssh'
|
28
|
+
# require 'stax/mixin/asg'
|
29
|
+
# require 'stax/mixin/ecs'
|
30
|
+
# require 'stax/mixin/ecr'
|
31
|
+
# require 'stax/mixin/sqs'
|
32
|
+
# require 'stax/mixin/kms'
|
33
|
+
# require 'stax/mixin/ssm'
|
34
|
+
# require 'stax/mixin/keypair'
|
35
|
+
# require 'stax/mixin/emr'
|
36
|
+
# require 'stax/mixin/ssh'
|
37
37
|
require 'stax/mixin/lambda'
|
38
38
|
require 'stax/mixin/dynamodb'
|
39
39
|
require 'stax/mixin/logs'
|
40
|
-
require 'stax/mixin/apigw'
|
41
|
-
require 'stax/mixin/firehose'
|
40
|
+
# require 'stax/mixin/apigw'
|
41
|
+
# require 'stax/mixin/firehose'
|
42
42
|
require 'stax/mixin/codebuild'
|
43
43
|
require 'stax/mixin/codepipeline'
|
44
|
-
require 'stax/mixin/rds'
|
45
|
-
require 'stax/mixin/cloudfront'
|
44
|
+
# require 'stax/mixin/rds'
|
45
|
+
# require 'stax/mixin/cloudfront'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -610,7 +610,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
610
610
|
- !ruby/object:Gem::Version
|
611
611
|
version: '0'
|
612
612
|
requirements: []
|
613
|
-
rubygems_version: 3.1.
|
613
|
+
rubygems_version: 3.1.6
|
614
614
|
signing_key:
|
615
615
|
specification_version: 4
|
616
616
|
summary: Control Cloudformation stack and other stuff.
|