Class: Stax::Cmd::S3
Instance Method Summary
collapse
Methods inherited from SubCommand
#info, stax_info, stax_info_tasks
Instance Method Details
#buckets ⇒ Object
43
44
45
|
# File 'lib/stax/mixin/s3.rb', line 43
def buckets
puts stack_s3_bucket_names
end
|
#clear ⇒ Object
115
116
117
118
119
120
121
122
|
# File 'lib/stax/mixin/s3.rb', line 115
def clear
debug("Clearing buckets for #{my.stack_name}")
(options[:names] || stack_s3_bucket_names).each do |b|
if yes?("Clear contents of bucket #{b}?", :yellow)
::Aws::S3::Bucket.new(b).clear!
end
end
end
|
#delete ⇒ Object
126
127
128
129
130
131
132
133
|
# File 'lib/stax/mixin/s3.rb', line 126
def delete
debug("Deleting buckets for #{my.stack_name}")
(options[:names] || stack_s3_bucket_names).each do |b|
if yes?("Delete bucket and contents #{b}?", :yellow)
::Aws::S3::Bucket.new(b).delete!
end
end
end
|
#expire(days = 1) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/stax/mixin/s3.rb', line 90
def expire(days = 1)
debug("Expiring objects in buckets tagged by #{my.stack_name}")
stack_tagged_buckets.each do |bucket|
if yes?("Expire all objects for #{bucket.name} in #{days}d?", :yellow)
Aws::S3.put_lifecycle(
bucket.name,
rules: [
{
prefix: '', status: :Enabled,
expiration: {
days: days,
},
noncurrent_version_expiration: {
noncurrent_days: days,
},
}
]
)
end
end
end
|
#lifecycle ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/stax/mixin/s3.rb', line 80
def lifecycle
debug("Lifecycle for buckets tagged by #{my.stack_name}")
stack_tagged_buckets.each do |bucket|
Aws::S3.get_lifecycle(bucket.name).each do |l|
puts YAML.dump(stringify_keys(l.to_hash))
end
end
end
|
#ls ⇒ Object
35
36
37
38
39
40
|
# File 'lib/stax/mixin/s3.rb', line 35
def ls
debug("Buckets for #{my.stack_name}")
print_table stack_s3_bucket_names.map { |b|
[ b, Aws::S3.location(b) ]
}
end
|
#reap ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/stax/mixin/s3.rb', line 70
def reap
debug("Deleting buckets tagged by #{my.stack_name}")
stack_tagged_buckets.each do |b|
if yes?("Delete bucket and contents #{b.name}?", :yellow)
::Aws::S3::Bucket.new(b.name).delete!
end
end
end
|
#tagged ⇒ Object
62
63
64
65
66
67
|
# File 'lib/stax/mixin/s3.rb', line 62
def tagged
debug("Buckets tagged by stack #{my.stack_name}")
print_table stack_tagged_buckets.map { |b|
[b.name, b.creation_date]
}
end
|
#website ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/stax/mixin/s3.rb', line 48
def website
stack_s3_bucket_names.each do |b|
debug("Website endpoint for #{b}")
begin
Aws::S3.client.get_bucket_website(bucket: b)
region = Aws::S3.location(b)
puts "#{b}.s3-website-#{region}.amazonaws.com"
rescue ::Aws::S3::Errors::NoSuchWebsiteConfiguration => e
puts e.message end
end
end
|