cloudformation-ruby-dsl 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0b2bb25bca9454ecbfbfbed8c3c5ce751734f22
|
4
|
+
data.tar.gz: a650a529257a400c4ff9aa1d09e0c4ac49d3ab52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3a22a8bac4c06712e353ef355c59e420347f60e95b33a985b273c7489e522b04eb012033ee2d7e25f3a2bd135599895923ef75b8f8f62cedb473d5da835d925
|
7
|
+
data.tar.gz: c7723d3e2c358621615d173f7b32877b510b78ba5939a8f29d04c85290939d500b3ac6a7276a435b4f94d063953e1a842aeb3136073bd7591f9bb075f72d4d50
|
@@ -167,8 +167,8 @@ template do
|
|
167
167
|
{:DeviceName => '/dev/sdd', :VirtualName => 'ephemeral2'},
|
168
168
|
{:DeviceName => '/dev/sde', :VirtualName => 'ephemeral3'},
|
169
169
|
],
|
170
|
-
# Loads an external userdata script.
|
171
|
-
:UserData => base64(interpolate(file('userdata.sh'))),
|
170
|
+
# Loads an external userdata script with an interpolated argument.
|
171
|
+
:UserData => base64(interpolate(file('userdata.sh'), time: Time.now)),
|
172
172
|
}
|
173
173
|
|
174
174
|
resource 'InstanceProfile', :Type => 'AWS::IAM::InstanceProfile', :Properties => {
|
data/examples/userdata.sh
CHANGED
@@ -325,7 +325,7 @@ class TemplateDSL < JsonObjectDSL
|
|
325
325
|
begin
|
326
326
|
# Figure out what the file extension is and process accordingly.
|
327
327
|
contents = case File.extname(filename)
|
328
|
-
when ".rb"; eval(file.read)
|
328
|
+
when ".rb"; eval(file.read, nil, filename)
|
329
329
|
when ".json"; JSON.load(file)
|
330
330
|
when ".yaml"; YAML::load(file)
|
331
331
|
else; raise("Do not recognize extension of #{filename}.")
|
@@ -414,12 +414,13 @@ def file(filename) File.read(File.absolute_path(filename, File.dirname($PROGRAM_
|
|
414
414
|
# Interpolates a string like "NAME={{ref('Service')}}" and returns a CloudFormation "Fn::Join"
|
415
415
|
# operation to collect the results. Anything between {{ and }} is interpreted as a Ruby expression
|
416
416
|
# and eval'd. This is especially useful with Ruby "here" documents.
|
417
|
-
|
417
|
+
# Local variables may also be exposed to the string via the `locals` hash.
|
418
|
+
def interpolate(string, locals={})
|
418
419
|
list = []
|
419
420
|
while string.length > 0
|
420
421
|
head, match, string = string.partition(/\{\{.*?\}\}/)
|
421
422
|
list << head if head.length > 0
|
422
|
-
list << eval(match[2..-3]) if match.length > 0
|
423
|
+
list << eval(match[2..-3], nil, 'interpolated string') if match.length > 0
|
423
424
|
end
|
424
425
|
|
425
426
|
# Split out strings in an array by newline, for visibility
|