stax 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stax.rb +2 -1
- data/lib/stax/aws/cloudfront.rb +25 -0
- data/lib/stax/aws/s3.rb +6 -0
- data/lib/stax/mixin/cloudfront.rb +67 -0
- data/lib/stax/mixin/s3.rb +25 -1
- data/lib/stax/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf4f4e043c476f43efbf2dabab7197b831ca7cfb467e63102d66a0758cb49b4c
|
4
|
+
data.tar.gz: 571a5d369568bd81bf6184e81e296926cfb7eb9fe904dfb931eedbcc16472909
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d4633373d3a5c724cf2908dee5dfe5dd8f628e5c731f2aac47274f9d67bb19e8548db886cc7ff1b4227d38da6c517705818a41cfb544f43b23a13497baee88
|
7
|
+
data.tar.gz: 31b0e98e8347e837b160eadddac03976b36ffd7f691b40e3719ce953eb62e5b6768eb414cd57fc53b961cb988a4685a538613967b4d08d30b619a15219cde64d
|
data/lib/stax.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Stax
|
2
|
+
module Aws
|
3
|
+
class Cloudfront < Sdk
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def client
|
7
|
+
@_client ||= ::Aws::CloudFront::Client.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def distribution(id)
|
11
|
+
client.get_distribution(id: id).distribution
|
12
|
+
end
|
13
|
+
|
14
|
+
def invalidations(id)
|
15
|
+
client.list_invalidations(distribution_id: id).map(&:invalidation_list).map(&:items)
|
16
|
+
end
|
17
|
+
|
18
|
+
def invalidation(distribution_id, id)
|
19
|
+
client.get_invalidation(distribution_id: distribution_id, id: id).invalidation
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/stax/aws/s3.rb
CHANGED
@@ -26,6 +26,12 @@ module Stax
|
|
26
26
|
client.get_bucket_location(bucket: bucket).location_constraint
|
27
27
|
end
|
28
28
|
|
29
|
+
## get region, return us-east-1 if empty
|
30
|
+
def location(bucket)
|
31
|
+
l = client.get_bucket_location(bucket: bucket).location_constraint
|
32
|
+
l.empty? ? 'us-east-1' : l
|
33
|
+
end
|
34
|
+
|
29
35
|
def put(opt)
|
30
36
|
client.put_object(opt)
|
31
37
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'stax/aws/cloudfront'
|
2
|
+
|
3
|
+
module Stax
|
4
|
+
module Cloudfront
|
5
|
+
def self.included(thor)
|
6
|
+
thor.desc('cloudfront COMMAND', 'Cloudfront subcommands')
|
7
|
+
thor.subcommand(:cloudfront, Cmd::Cloudfront)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Cmd
|
12
|
+
class Cloudfront < SubCommand
|
13
|
+
stax_info :ls
|
14
|
+
|
15
|
+
COLORS = {
|
16
|
+
Enabled: :green,
|
17
|
+
Disabled: :red,
|
18
|
+
Completed: :green,
|
19
|
+
}
|
20
|
+
|
21
|
+
no_commands do
|
22
|
+
def stack_cloudfront_distributions
|
23
|
+
@_stack_cloudfront_distributions ||= Aws::Cfn.resources_by_type(my.stack_name, 'AWS::CloudFront::Distribution')
|
24
|
+
end
|
25
|
+
|
26
|
+
def stack_cloudfront_ids
|
27
|
+
stack_cloudfront_distributions.map(&:physical_resource_id)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'ls', 'list cloudfront distributions for stack'
|
32
|
+
def ls
|
33
|
+
debug("Cloudfront distributions for #{my.stack_name}")
|
34
|
+
print_table stack_cloudfront_ids.map { |id|
|
35
|
+
d = Aws::Cloudfront.distribution(id)
|
36
|
+
[
|
37
|
+
d.id,
|
38
|
+
d.domain_name,
|
39
|
+
d.status,
|
40
|
+
color(d.distribution_config.enabled ? :Enabled : :Disabled, COLORS),
|
41
|
+
d.last_modified_time,
|
42
|
+
]
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'domains', 'list cloudfront domains'
|
47
|
+
def domains
|
48
|
+
puts stack_cloudfront_ids.map { |id|
|
49
|
+
Aws::Cloudfront.distribution(id).domain_name
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'invalidations', 'list invalidations for distributions'
|
54
|
+
def invalidations
|
55
|
+
stack_cloudfront_ids.each do |id|
|
56
|
+
debug("Invalidations for distribution #{id}")
|
57
|
+
Aws::Cloudfront.invalidations(id).each { |list|
|
58
|
+
print_table list.map { |inv|
|
59
|
+
i = Aws::Cloudfront.invalidation(id, inv.id)
|
60
|
+
[ i.id, color(i.status, COLORS), i.create_time ]
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/stax/mixin/s3.rb
CHANGED
@@ -10,6 +10,8 @@ module Stax
|
|
10
10
|
|
11
11
|
module Cmd
|
12
12
|
class S3 < SubCommand
|
13
|
+
stax_info :ls
|
14
|
+
|
13
15
|
no_commands do
|
14
16
|
def stack_s3_buckets
|
15
17
|
Aws::Cfn.resources_by_type(my.stack_name, 'AWS::S3::Bucket')
|
@@ -29,11 +31,33 @@ module Stax
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
desc '
|
34
|
+
desc 'ls', 'list buckets and regions'
|
35
|
+
def ls
|
36
|
+
debug("Buckets for #{my.stack_name}")
|
37
|
+
print_table stack_s3_bucket_names.map { |b|
|
38
|
+
[ b, Aws::S3.location(b) ]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'buckets', 'S3 bucket names for this stack'
|
33
43
|
def buckets
|
34
44
|
puts stack_s3_bucket_names
|
35
45
|
end
|
36
46
|
|
47
|
+
desc 'website', 'guess website endpoint for buckets'
|
48
|
+
def website
|
49
|
+
stack_s3_bucket_names.each do |b|
|
50
|
+
debug("Website endpoint for #{b}")
|
51
|
+
begin
|
52
|
+
Aws::S3.client.get_bucket_website(bucket: b)
|
53
|
+
region = Aws::S3.location(b)
|
54
|
+
puts "#{b}.s3-website-#{region}.amazonaws.com"
|
55
|
+
rescue ::Aws::S3::Errors::NoSuchWebsiteConfiguration => e
|
56
|
+
puts e.message # handle no website config
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
37
61
|
desc 'tagged', 'S3 buckets that were tagged by this stack'
|
38
62
|
def tagged
|
39
63
|
debug("Buckets tagged by stack #{my.stack_name}")
|
data/lib/stax/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.17
|
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-
|
11
|
+
date: 2019-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/stax/aws/apigw.rb
|
162
162
|
- lib/stax/aws/asg.rb
|
163
163
|
- lib/stax/aws/cfn.rb
|
164
|
+
- lib/stax/aws/cloudfront.rb
|
164
165
|
- lib/stax/aws/codebuild.rb
|
165
166
|
- lib/stax/aws/codepipeline.rb
|
166
167
|
- lib/stax/aws/dms.rb
|
@@ -212,6 +213,7 @@ files:
|
|
212
213
|
- lib/stax/mixin/alb.rb
|
213
214
|
- lib/stax/mixin/apigw.rb
|
214
215
|
- lib/stax/mixin/asg.rb
|
216
|
+
- lib/stax/mixin/cloudfront.rb
|
215
217
|
- lib/stax/mixin/codebuild.rb
|
216
218
|
- lib/stax/mixin/codepipeline.rb
|
217
219
|
- lib/stax/mixin/dms.rb
|
@@ -271,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
273
|
version: '0'
|
272
274
|
requirements: []
|
273
275
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.7.6
|
276
|
+
rubygems_version: 2.7.6.2
|
275
277
|
signing_key:
|
276
278
|
specification_version: 4
|
277
279
|
summary: Control Cloudformation stack and other stuff.
|