Class: Awful::CloudFront
- Inherits:
-
Cli
show all
- Defined in:
- lib/awful/cloudfront.rb
Constant Summary
collapse
- COLORS =
{
enabled: :green,
disabled: :red,
deployed: :green,
inprogress: :yellow,
}
Instance Method Summary
collapse
Methods inherited from Cli
#initialize, #ll, #version
Constructor Details
This class inherits a constructor from Awful::Cli
Instance Method Details
#aliases(id, *list) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/awful/cloudfront.rb', line 65
def aliases(id, *list)
if list.empty?
cloudfront.get_distribution(id: id).distribution.distribution_config.aliases.items.output(&method(:puts))
else
response = cloudfront.get_distribution(id: id) config = response.distribution.distribution_config
new = config[:aliases][:items]
if options[:add]
new += list elsif options[:delete]
new -= list else
new = list end
config[:aliases] = {quantity: new.count, items: new}
cloudfront.update_distribution(id: id, distribution_config: config, if_match: response.etag)
end
end
|
49
50
51
52
53
|
# File 'lib/awful/cloudfront.rb', line 49
def get(id)
cloudfront.get_distribution(id: id).distribution.output do |dist|
puts YAML.dump(stringify_keys(dist.to_hash))
end
end
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/awful/cloudfront.rb', line 25
def ls
marker = nil
items = []
loop do
response = cloudfront.list_distributions(marker: marker).distribution_list
items += response.items
marker = response.next_marker
break unless marker
end
items.output do |list|
if options[:long]
print_table list.map { |i|
origins = i.origins.items.map(&:domain_name).join(',').slice(0..40)
state = i.enabled ? :Enabled : :Disabled
[ i.id, i.domain_name, i., origins, color(i.status), color(state), i.last_modified_time ]
}
else
puts list.map(&:id).sort
end
end
end
|
#origins(id) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/awful/cloudfront.rb', line 86
def origins(id)
cloudfront.get_distribution(id: id).distribution.distribution_config.origins.items.output do |list|
if options[:long]
print_table list.map { |o|
c = o.custom_origin_config
config = o.s3_origin_config ? [ 's3' ] : [ 'custom', c.origin_protocol_policy, c.http_port, c.https_port ]
[ o.id, o.domain_name, o.origin_path ] + config
}
else
puts list.map(&:id).sort
end
end
end
|
#status(id) ⇒ Object
56
57
58
59
60
|
# File 'lib/awful/cloudfront.rb', line 56
def status(id)
cloudfront.get_distribution(id: id).distribution.status.output do |status|
puts color(status)
end
end
|