bora 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/lib/bora/cfn_param_resolver.rb +12 -4
- data/lib/bora/rake_tasks.rb +20 -9
- data/lib/bora/tasks.rb +1 -1
- data/lib/bora/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afc84ca6ace21cd7997bea10fd35850740536f13
|
4
|
+
data.tar.gz: 5e7df220869080122165cd28082d4c1e024320fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfbf29a13e209ddd100e88150d5e6cccf76b118fea3c4f7dcc739e83cd38c33070763d6cfe92fa0c1bda3f074a079d6570e2d5d83c5f856f438c71e893c2de73
|
7
|
+
data.tar.gz: 0f34aa4bf376a58b367d61c0187a206cbc197be67c2dcb4d200d374de6c5435fde0138eebf846bb8a97c9c8deb4ea23e3521987c9a679f819b990872df5652c9
|
data/README.md
CHANGED
@@ -126,6 +126,45 @@ end
|
|
126
126
|
puts "Update #{result ? "succeeded" : "failed"}"
|
127
127
|
```
|
128
128
|
|
129
|
+
### YAML Configuration - Experimental
|
130
|
+
You can define and configure your stacks through YAML too.
|
131
|
+
This interface is currently experimental,
|
132
|
+
but longer term is likely to become the primary way to use this gem.
|
133
|
+
Sample usage is shown below (subject to change).
|
134
|
+
|
135
|
+
Rakefile:
|
136
|
+
```ruby
|
137
|
+
require "bora"
|
138
|
+
Bora::RakeTasks.new('templates.yml')
|
139
|
+
```
|
140
|
+
|
141
|
+
templates.yml:
|
142
|
+
```yaml
|
143
|
+
templates:
|
144
|
+
app:
|
145
|
+
template_file: templates/test.json
|
146
|
+
stacks:
|
147
|
+
dev: {}
|
148
|
+
uat: {}
|
149
|
+
|
150
|
+
web:
|
151
|
+
# Templates ending in ".rb" are treated as cfndsl templates
|
152
|
+
template_file: templates/test.rb
|
153
|
+
capabilities: [CAPABILITY_IAM]
|
154
|
+
stacks:
|
155
|
+
dev:
|
156
|
+
# Set stack name explicitly (otherwise would default to "web-dev")
|
157
|
+
stack_name: foo-dev
|
158
|
+
params:
|
159
|
+
# Look up a value from the outputs of the "app-dev"stack
|
160
|
+
app_sg: ${app-dev/outputs/AppSecurityGroup}
|
161
|
+
uat:
|
162
|
+
params:
|
163
|
+
app_sg: foouatdev
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
|
129
168
|
## Development
|
130
169
|
|
131
170
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -7,14 +7,22 @@ module Bora
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def resolve
|
10
|
-
|
11
|
-
if !
|
10
|
+
stack_name, section, name = @param.split("/")
|
11
|
+
if !stack_name || !section || !name || section != 'outputs'
|
12
12
|
raise "Invalid parameter substitution: #{@param}"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
stack = Stack.new(stack_name)
|
16
|
+
if !stack.exists?
|
17
|
+
raise "Output #{name} not found in stack #{stack_name} as the stack does not exist"
|
18
|
+
end
|
19
|
+
|
20
|
+
outputs = stack.outputs || []
|
16
21
|
matching_output = outputs.find { |output| output.key == name }
|
17
|
-
|
22
|
+
if !matching_output
|
23
|
+
raise "Output #{name} not found in stack #{stack_name}"
|
24
|
+
end
|
25
|
+
|
18
26
|
matching_output.value
|
19
27
|
end
|
20
28
|
|
data/lib/bora/rake_tasks.rb
CHANGED
@@ -32,15 +32,26 @@ module Bora
|
|
32
32
|
|
33
33
|
def define_tasks(template_file, stack_name, stack_config, stack_options)
|
34
34
|
Bora::Tasks.new(stack_name) do |t|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
t.stack_options = stack_options
|
36
|
+
|
37
|
+
task :generate do |_, args|
|
38
|
+
params = extract_params(stack_config, args)
|
39
|
+
t.stack_options[:parameters] = params.map do |k,v|
|
40
|
+
{ parameter_key: k, parameter_value: v }
|
41
|
+
end
|
42
|
+
|
43
|
+
if File.extname(template_file) == ".rb"
|
44
|
+
template_body = run_cfndsl(template_file, params)
|
45
|
+
template_json = JSON.parse(template_body)
|
46
|
+
if template_json["Parameters"]
|
47
|
+
cfn_params = template_json["Parameters"].keys
|
48
|
+
t.stack_options[:parameters].keep_if {|cfn_param| cfn_params.include?(cfn_param[:parameter_key]) }
|
49
|
+
end
|
50
|
+
t.stack_options[:template_body] = template_body
|
51
|
+
else
|
52
|
+
t.stack_options[:template_url] = template_file
|
39
53
|
end
|
40
|
-
else
|
41
|
-
stack_options[:template_url] = template_file
|
42
54
|
end
|
43
|
-
t.stack_options = stack_options
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
@@ -61,10 +72,10 @@ module Bora
|
|
61
72
|
def extract_params(stack_config, args)
|
62
73
|
params = stack_config['params'] || {}
|
63
74
|
params.merge!(extract_params_from_args(args.extras))
|
64
|
-
params.map { |k, v| [k,
|
75
|
+
params.map { |k, v| [k, process_param_substitutions(v)] }.to_h
|
65
76
|
end
|
66
77
|
|
67
|
-
def
|
78
|
+
def process_param_substitutions(val)
|
68
79
|
old_val = nil
|
69
80
|
while old_val != val
|
70
81
|
old_val = val
|
data/lib/bora/tasks.rb
CHANGED
data/lib/bora/version.rb
CHANGED