-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch
40 lines (33 loc) · 1.2 KB
/
launch
1
2
3
4
5
6
7
8
9
10
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
#!/usr/bin/env ruby
require 'yaml'
def parsed_envs(delimeter)
hash = {}
if File.exists?('overrides.yml')
items = YAML::load(File.open("overrides.yml"))
exit('Nothing in your overrides.yml file!') if !items
result = ""
items.each do |k,v|
if v.class == String
while !v.index('{{').nil? do
str1 = "{{"
str2 = "}}"
v.sub!(v[/(\{\{.*?\}\})/, 1], hash[v[/#{str1}(.*?)#{str2}/m, 1].strip.to_sym])
end
end
hash[k.strip.to_sym] = v
result += "#{k}=#{v}#{delimeter}"
end
return result.slice(0, result.length-1)
else
puts 'Launch Error: You have not set up your overrides! Copy overrides.yml.template into overrides.yml and make appropriate changes.'
exit
end
end
# generate Dockerrun.aws.json file
if !File.directory?('.elasticbeanstalk')
system "eb init" #<-- pass through typrical information, DNS name, region etc
# Create the environment
system "eb create --timeout 900 --database --envvars #{parsed_envs(',')}" # add more options to tailor the environment
end
# set environment variables needed for the deploy.
system "eb setenv #{parsed_envs(' ')} --timeout 900" # script that parses the overrides into K=V style