stax 0.1.8 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/stax +3 -1
- data/lib/stax/aws/cfn.rb +1 -0
- 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/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: 62a62442fc3683b993fbaecb2ea165f78da8b057314f745c582c62a9ca5cbe37
|
4
|
+
data.tar.gz: 8c5bf0945d8bd817c083a2defcdda7fdc40809d165391e31550c2e5597cb02a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7fc989c78022f0252acbe5ef75a0b4f6806e19cc6a7a40df3088b00820d7285acd8721334491602b94e7aea2f3dfa1ffb66ca1ad2c5d4b8bde56f9700d363fb
|
7
|
+
data.tar.gz: 3af7fee718d39db56438b1184d75e93dc62241c6885ee0af843c14aa6344a9d669a41ce88fff5c851bad3675c2ded2a560f797ffc97b221e0422edeb30332f5a
|
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/aws/cfn.rb
CHANGED
@@ -7,6 +7,7 @@ module Stax
|
|
7
7
|
CREATE_IN_PROGRESS CREATE_FAILED CREATE_COMPLETE
|
8
8
|
ROLLBACK_IN_PROGRESS ROLLBACK_FAILED ROLLBACK_COMPLETE
|
9
9
|
DELETE_IN_PROGRESS DELETE_FAILED
|
10
|
+
IMPORT_IN_PROGRESS IMPORT_COMPLETE IMPORT_ROLLBACK_IN_PROGRESS IMPORT_ROLLBACK_FAILED IMPORT_ROLLBACK_COMPLETE
|
10
11
|
UPDATE_IN_PROGRESS UPDATE_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_COMPLETE
|
11
12
|
UPDATE_ROLLBACK_IN_PROGRESS UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE
|
12
13
|
REVIEW_IN_PROGRESS
|
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?
|
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.11
|
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-03-28 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.
|