stax 0.0.20 → 0.0.21

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: 7ab1308aae152e3ce07dfed495c2b4b58cd69704e27326bfd58e60ff48735d17
4
- data.tar.gz: 8c8e49936354d5adbfa2b9d437e26c49703daea389ddc06db1db149893351cd7
3
+ metadata.gz: 40f1d0e0ef7606928243ab90e197a23a3662bc98412172c5cee932e47ac17a4e
4
+ data.tar.gz: 30a497d05e974e81d13f5afd2f612b79ca2de486efe1102aee6552a6cd6e49aa
5
5
  SHA512:
6
- metadata.gz: a802b136d63a2d0be61f43efc8da2de0d98f3caa1187f86dd3dad37ac5fc48af8031aa7f8e19fd176f6be014a13b31f5f6f29c176631b67677b5edf25d8d67d6
7
- data.tar.gz: ac24f8745af2252e776a6d0f6060766e51f28f782f3caf69f09a82ef3a36c90fdead05437c7480d2714efd4097e876d6ecae81ffd6fccc2771964d060891ed4e
6
+ metadata.gz: '0935849ccad8faab8bff84fa8a713cb5dc12c6d68ccb505c21eb17bb2f94abc0f8b4473141b8c3e539eb0640602670bbfe3c220c95fd3a9499fda8b6e5fb4151'
7
+ data.tar.gz: cdf046837d9c381807f86349efbc786928e5c0bbc320d5a118af2d763b012cff6c883f228a91672b20fb0a3f008ba24932cdb2d67fd69e854d5e8061ad1ebeed
@@ -0,0 +1,19 @@
1
+ module Stax
2
+ module Aws
3
+ class Acm < Sdk
4
+
5
+ class << self
6
+
7
+ def client
8
+ @_client ||= ::Aws::ACM::Client.new
9
+ end
10
+
11
+ def describe(arn)
12
+ client.describe_certificate(certificate_arn: arn)&.certificate
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,81 @@
1
+ require 'stax/aws/acm'
2
+
3
+ module Stax
4
+ module Acm
5
+ def self.included(thor)
6
+ thor.desc('acm COMMAND', 'ACM subcommands')
7
+ thor.subcommand(:acm, Cmd::Acm)
8
+ end
9
+ end
10
+
11
+ module Cmd
12
+ class Acm < SubCommand
13
+
14
+ COLORS = {
15
+ SUCCESS: :green,
16
+ PENDING_VALIDATION: :yellow,
17
+ }
18
+
19
+ no_commands do
20
+ def stack_acm_certs
21
+ Aws::Cfn.resources_by_type(my.stack_name, 'AWS::CertificateManager::Certificate')
22
+ end
23
+
24
+ def route53_change_batch(record)
25
+ {
26
+ Comment: 'validation',
27
+ Changes: [
28
+ {
29
+ Action: :UPSERT,
30
+ ResourceRecordSet: {
31
+ Name: record.name,
32
+ Type: record.type,
33
+ TTL: 300,
34
+ ResourceRecords: [ {Value: record.value} ]
35
+ }
36
+ }
37
+ ]
38
+ }.to_json
39
+ end
40
+ end
41
+
42
+ desc 'ls', 'list ACM certs'
43
+ def ls
44
+ print_table stack_acm_certs.map { |r|
45
+ c = Aws::Acm.describe(r.physical_resource_id)
46
+ in_use = c.in_use_by.empty? ? 'not in use' : 'in use'
47
+ [ c.domain_name, color(c.status, COLORS), c.issuer, in_use, c.created_at ]
48
+ }
49
+ end
50
+
51
+ desc 'domains', 'list domains for certs'
52
+ def domains
53
+ stack_acm_certs.each do |r|
54
+ c = Aws::Acm.describe(r.physical_resource_id)
55
+ debug("Domains for #{c.certificate_arn}")
56
+ print_table c.domain_validation_options.map { |d|
57
+ [ d.domain_name, color(d.validation_status, COLORS), d.validation_method ]
58
+ }
59
+ end
60
+ end
61
+
62
+ desc 'validation', 'list pending validation records for certs'
63
+ method_option :cli, type: :boolean, default: false, desc: 'show aws cli command for route53 change'
64
+ def validation
65
+ stack_acm_certs.each do |r|
66
+ c = Aws::Acm.describe(r.physical_resource_id)
67
+ c.domain_validation_options.each do |d|
68
+ next if d.validation_status == 'SUCCESS'
69
+ debug("Pending validation for #{d.domain_name}")
70
+ if options[:cli]
71
+ puts "aws route53 change-resource-record-sets --change-batch '#{route53_change_batch(d.resource_record)}' --hosted-zone-id ..."
72
+ else
73
+ puts([d.resource_record.name, d.resource_record.type, d.resource_record.value].join(' '))
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+ end
81
+ end
@@ -1,3 +1,3 @@
1
1
  module Stax
2
- VERSION = '0.0.20'
2
+ VERSION = '0.0.21'
3
3
  end
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.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -157,6 +157,7 @@ files:
157
157
  - bin/setup
158
158
  - bin/stax
159
159
  - lib/stax.rb
160
+ - lib/stax/aws/acm.rb
160
161
  - lib/stax/aws/alb.rb
161
162
  - lib/stax/aws/apigw.rb
162
163
  - lib/stax/aws/asg.rb
@@ -210,6 +211,7 @@ files:
210
211
  - lib/stax/github.rb
211
212
  - lib/stax/iam.rb
212
213
  - lib/stax/keypair.rb
214
+ - lib/stax/mixin/acm.rb
213
215
  - lib/stax/mixin/alb.rb
214
216
  - lib/stax/mixin/apigw.rb
215
217
  - lib/stax/mixin/asg.rb