Class: CfnResponse::Builder
- Inherits:
-
Base
- Object
- Base
- CfnResponse::Builder
show all
- Defined in:
- lib/cfn_response/builder.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#call(input = {}) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/cfn_response/builder.rb', line 3
def call(input={})
input.transform_keys! { |k| k.to_s }
default = {
"Reason" => default_reason,
"Status" => "SUCCESS",
"PhysicalResourceId" => physical_resource_id(input["PhysicalResourceId"])
}
resp = default.merge(input)
verbatim = @event.slice("StackId", "RequestId", "LogicalResourceId") verbatim.merge(resp) end
|
#current_physical_resource_id ⇒ Object
35
36
37
|
# File 'lib/cfn_response/builder.rb', line 35
def current_physical_resource_id
@event["PhysicalResourceId"] || "PhysicalResourceId"
end
|
#default_reason ⇒ Object
39
40
41
|
# File 'lib/cfn_response/builder.rb', line 39
def default_reason
"See the details in CloudWatch Log Group: #{@context.log_group_name} Log Stream: #{@context.log_stream_name}"
end
|
#new_physical_resource_id ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/cfn_response/builder.rb', line 27
def new_physical_resource_id
regexp = /(\d+$)/
md = current_physical_resource_id.match(regexp) n = md ? md[1].to_i + 1 : 1
basename = current_physical_resource_id.sub(regexp,'') "#{basename}#{n}"
end
|
#physical_resource_id(id) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/cfn_response/builder.rb', line 17
def physical_resource_id(id)
if id.nil?
current_physical_resource_id
elsif id == :new_physical_resource_id or id == :new_id
new_physical_resource_id
else
id
end
end
|