Class: Putpaws::Provision::Resources::LogGroup
- Inherits:
-
Base
- Object
- Base
- Putpaws::Provision::Resources::LogGroup
show all
- Defined in:
- lib/putpaws/provision/resources/log_group.rb
Instance Attribute Summary
Attributes inherited from Base
#clients, #config, #state
Instance Method Summary
collapse
Methods inherited from Base
#ensure!, #kind, #plan
Constructor Details
#initialize(log_group_name:, output_key:, **args) ⇒ LogGroup
Returns a new instance of LogGroup.
7
8
9
10
11
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 7
def initialize(log_group_name:, output_key:, **args)
super(**args)
@log_group_name = log_group_name
@output_key = output_key
end
|
Instance Method Details
#changed?(current) ⇒ Boolean
26
27
28
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 26
def changed?(current)
current.retention_in_days != retention_in_days
end
|
#create! ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 30
def create!
clients.logs.create_log_group(
log_group_name: name,
tags: {MANAGED_TAG[:key] => MANAGED_TAG[:value]}
)
clients.logs.put_retention_policy(log_group_name: name, retention_in_days: retention_in_days)
{@output_key => name}
end
|
#current ⇒ Object
21
22
23
24
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 21
def current
res = clients.logs.describe_log_groups(log_group_name_prefix: name)
res.log_groups.detect{|g| g.log_group_name == name}
end
|
#name ⇒ Object
13
14
15
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 13
def name
@log_group_name
end
|
#outputs(_current) ⇒ Object
44
45
46
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 44
def outputs(_current)
{@output_key => name}
end
|
#retention_in_days ⇒ Object
17
18
19
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 17
def retention_in_days
(config.settings[:log_retention_days] || 30).to_i
end
|
#update!(_current) ⇒ Object
39
40
41
42
|
# File 'lib/putpaws/provision/resources/log_group.rb', line 39
def update!(_current)
clients.logs.put_retention_policy(log_group_name: name, retention_in_days: retention_in_days)
{@output_key => name}
end
|