Class: Stax::Cmd::S3
Instance Method Summary
collapse
Methods inherited from SubCommand
#info, stax_info, stax_info_tasks
Instance Method Details
#buckets ⇒ Object
33
34
35
|
# File 'lib/stax/mixin/s3.rb', line 33
def buckets
puts stack_s3_bucket_names
end
|
#clear ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/stax/mixin/s3.rb', line 91
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
102
103
104
105
106
107
108
109
|
# File 'lib/stax/mixin/s3.rb', line 102
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/stax/mixin/s3.rb', line 66
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
56
57
58
59
60
61
62
63
|
# File 'lib/stax/mixin/s3.rb', line 56
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
|
#reap ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/stax/mixin/s3.rb', line 46
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
38
39
40
41
42
43
|
# File 'lib/stax/mixin/s3.rb', line 38
def tagged
debug("Buckets tagged by stack #{my.stack_name}")
print_table stack_tagged_buckets.map { |b|
[b.name, b.creation_date]
}
end
|