11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/aws-int-test-rspec-helper.rb', line 11
def stack(stack_name:,
path_to_stack:,
bindings: nil)
full_stack_name = "#{stack_name}#{Time.now.to_i}"
= []
unless bindings.nil?
temp_file = Tempfile.new('cfnstackfortesting')
temp_file.write bindings.to_yaml
temp_file.close
<< [:yaml,File.expand_path(temp_file)]
end
verbose = false
model = CfnDsl::(File.expand_path(path_to_stack),
,
verbose)
resource = Aws::CloudFormation::Resource.new
created_stack = resource.create_stack(stack_name: full_stack_name,
template_body: model.to_json,
disable_rollback: true,
capabilities: %w{CAPABILITY_IAM})
created_stack.wait_until(max_attempts:100, delay:15) {|stack| stack.stack_status == 'CREATE_COMPLETE' }
@stack_outputs = created_stack.outputs.inject({}) do |hash, output|
hash[output.output_key] = output.output_value
hash
end
full_stack_name
end
|